Request small targetlist for input to WindowAgg.
authorAndrew Gierth <rhodiumtoad@postgresql.org>
Wed, 6 Nov 2019 04:13:30 +0000 (04:13 +0000)
committerAndrew Gierth <rhodiumtoad@postgresql.org>
Wed, 6 Nov 2019 04:13:30 +0000 (04:13 +0000)
commita9056cc637f2d183eefa165ebbd0308d9a89abb9
treea267befe91e800c8a0a504a19bfd4abf8df0007d
parent979766c0afceb95c4b96323b57a0f6edf8472612
Request small targetlist for input to WindowAgg.

WindowAgg will potentially store large numbers of input rows into
tuplestores to allow access to other rows in the frame. If the input
is coming via an explicit Sort node, then unneeded columns will
already have been discarded (since Sort requests a small tlist); but
there are idioms like COUNT(*) OVER () that result in the input not
being sorted at all, and cases where the input is being sorted by some
means other than a Sort; if we don't request a small tlist, then
WindowAgg's storage requirement is inflated by the unneeded columns.

Backpatch back to 9.6, where the current tlist handling was added.
(Prior to that, WindowAgg would always use a small tlist.)

Discussion: https://postgr.es/m/87a7ator8n.fsf@news-spur.riddles.org.uk
src/backend/optimizer/plan/createplan.c