Re: Endgame for all those SELECT FOR UPDATE changes: fix plan node order - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Endgame for all those SELECT FOR UPDATE changes: fix plan node order
Date
Msg-id 2399.1256528426@sss.pgh.pa.us
Whole thread Raw
In response to Re: Endgame for all those SELECT FOR UPDATE changes: fix plan node order  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Endgame for all those SELECT FOR UPDATE changes: fix plan node order
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Oct 25, 2009, at 10:34 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> ...  The solution for the second
>> one is to also put LockRows underneath the Sort node, and to regard its
>> output as unsorted so that a Sort node will certainly be generated.
>> (This in turn implies that we should prefer the cheapest-total plan
>> for the rest of the query.)

> This seems like it could potentially introduce a performance  
> regression, but the current behavior is so bizarre that it seems like  
> we should still change it.

Yeah, it could definitely run slower than the existing code --- in
particular the combination of all three (FOR UPDATE ORDER BY LIMIT)
would tend to become a seqscan-and-sort rather than possibly just
reading one end of an index.  However, I quote the old aphorism that
it can be made indefinitely fast if it doesn't have to give the right
answer.  The reason the current behavior is fast is it's giving the
wrong answer :-(
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Endgame for all those SELECT FOR UPDATE changes: fix plan node order
Next
From: Greg Smith
Date:
Subject: Re: Parsing config files in a directory