Re: updated SORT/LIMIT patch - Mailing list pgsql-patches

From Tom Lane
Subject Re: updated SORT/LIMIT patch
Date
Msg-id 4835.1178300660@sss.pgh.pa.us
Whole thread Raw
In response to Re: updated SORT/LIMIT patch  (Gregory Stark <stark@enterprisedb.com>)
Responses Re: updated SORT/LIMIT patch
List pgsql-patches
Gregory Stark <stark@enterprisedb.com> writes:
> Hum. The major change I see is the bit related to rescans where you made it
> resort if the bound had changed. But surely the only way the bound can change
> is if it's a parameter, and if there is a parameter then surely the executor
> must be doing more than just a plain rescan?

The problem is that a parameter change in the LIMIT's expression would
not normally be propagated below the LIMIT.  In this case, since we're
allowing its effects to bubble down one more level of the tree, we need
to make sure that that level is recomputed too.

> What does the executor do differently in the case of a subplan with a
> parameter that makes it re-execute the plan from scratch and not just do a
> simple rescan?

Look at the chgParam signaling.  Since a Sort node itself has no
parameters, it historically has only had to re-sort if its input node
suffers a parameter change, which it checks in ExecReScanSort.  But now
the bound effectively acts like a parameter, and has to force a
recomputation.

            regards, tom lane

pgsql-patches by date:

Previous
From: Gregory Stark
Date:
Subject: Re: updated SORT/LIMIT patch
Next
From: "Jie Zhang"
Date:
Subject: Re: Updated bitmap index patch