Re: Determine if FOR UPDATE or FOR SHARE was used?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chapman Flack <chap(at)anastigmatix(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Determine if FOR UPDATE or FOR SHARE was used?
Date: 2019-03-18 04:45:19
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Chapman Flack <chap(at)anastigmatix(dot)net> writes:
> Given a Portal, or an _SPI_plan, is there a practical way to tell whether
> it came from a query with FOR UPDATE or FOR SHARE?

In principle, you could do something like drilling down into the plan
tree to see if there's a LockRows node, but this wouldn't necessarily
be a great idea from a modularity or maintainability standpoint.

I think it would help to take two steps back and ask why you want
to know this, and what exactly is it that you want to know, anyhow.
What does it matter if there's FOR SHARE in the query? Does it
matter if the FOR SHARE targets only some tables (and do you
care which ones?) How would your answer change if the FOR SHARE
were buried down in a CTE subquery? Why are you only interested
in these cases, and not INSERT/UPDATE/DELETE?

regards, tom lane

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2019-03-18 05:13:34 Re: Unaccent extension python script Issue in Windows
Previous Message David Rowley 2019-03-18 04:20:32 Re: Performance issue in foreign-key-aware join estimation