Re: On the need for a snapshot in exec_bind_message()

From: Daniel Wood <hexexpert(at)comcast(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: On the need for a snapshot in exec_bind_message()
Date: 2018-09-05 23:17:48
Message-ID: 585373704.628375.1536189469835@connect.xfinity.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > Queries stop getting re-optimized after 5 times, unless better plans are to be had. In the absence of schema changes or changing search path why is the snapshot needed?
>
> The snapshot has little to do with the query plan, usually. It's about
> what view of the database the executed query will see, and particularly
> about what view the parameter input functions will see, if they look.
>
> You could maybe argue that immutable input functions shouldn't need
> snapshots, but there are enough not-immutable ones that I don't think
> that gets you very far. In any case, we'd still need a snapshot for
> query execution. The set of queries that could possibly never need
> a snapshot at all is probably not large enough to be interesting.

I would think that the vast majority of bind variables in customer queries would involve built-in data types whose input functions are immutable. As far as the "view of the database the executed query will see" goes, either the database itself changes, which should trigger catcache invalidations, that can be accounted for, or the "view" changes as in searchpath which can be tested for. I would think the optimization would be applicable most of the time. It isn't the number of obscure user created non-immutable input functions that exist. It is the frequency with which immutable input functions are used in real app's. This is a 50% performance improvement in point lookups on larger boxes.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-09-05 23:25:39 Re: On the need for a snapshot in exec_bind_message()
Previous Message Tom Lane 2018-09-05 23:11:56 Re: On the need for a snapshot in exec_bind_message()