Re: Determine if FOR UPDATE or FOR SHARE was used? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Determine if FOR UPDATE or FOR SHARE was used?
Date
Msg-id 4850.1552884319@sss.pgh.pa.us
Whole thread Raw
In response to Determine if FOR UPDATE or FOR SHARE was used?  (Chapman Flack <chap@anastigmatix.net>)
Responses Re: Determine if FOR UPDATE or FOR SHARE was used?
List pgsql-hackers
Chapman Flack <chap@anastigmatix.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


pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Performance issue in foreign-key-aware join estimation
Next
From: Kyotaro HORIGUCHI
Date:
Subject: Re: Unaccent extension python script Issue in Windows