Re: Why cann't simplify stable function in planning phase?

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, tender wang <tndrwang(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Why cann't simplify stable function in planning phase?
Date: 2023-02-08 16:15:19
Message-ID: 20230208161519.xmefe25d6vnbkja7@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2023-02-08 09:57:04 -0500, Tom Lane wrote:
> Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> writes:
> > Note: To be precise this is not about "executions" but about snapshots,
> > and we could probably simplify the function call with isolation levels
> > that maintain a single snapshot (e.g. REPEATABLE READ). But we don't.
>
> We don't do that because, in fact, execution is *never* done with the same
> snapshot used for planning. See comment in postgres.c:
>
> * While it looks promising to reuse the same snapshot for query
> * execution (at least for simple protocol), unfortunately it causes
> * execution to use a snapshot that has been acquired before locking
> * any of the tables mentioned in the query. This creates user-
> * visible anomalies, so refrain. Refer to
> * https://postgr.es/m/flat/5075D8DF(dot)6050500(at)fuzzy(dot)cz for details.
>
> I'm not entirely sure that that locking argument still holds, but having
> been burned once I'm pretty hesitant to try that again.

Because we now avoid re-computing snapshots, if there weren't any concurrent
commits/aborts, the gain would likely not be all that high anyway.

We should work on gettting rid of the ProcArrayLock acquisition in case we can
reuse the snapshot, though. I think it's doable safely, but when working on
it, I didn't succeed at writing a concise description as to why it's sfae, so
I decided that the rest of the wins are big enough to not focus on it then and
there.

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-02-08 16:23:10 Re: meson: Non-feature feature options
Previous Message Tom Lane 2023-02-08 16:02:24 Re: OpenSSL 3.0.0 vs old branches