Re: Todo: Teach planner to evaluate multiple windows in the optimal order

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Ankit Kumar Pandey <itsankitkp@gmail.com>, pghackers <pgsql-hackers@lists.postgresql.org>, Vik Fearing <vik@postgresfriends.org>
Date: 2023-01-10T05:36:54Z
Lists: pgsql-hackers
David Rowley <dgrowleyml@gmail.com> writes:
> Ideally, our sort costing would just be better, but I think that
> raises the bar a little too high to start thinking of making
> improvements to that for this patch.

It's trickier than it looks, cf f4c7c410e.  But if you just want
to add a small correction based on number of columns being sorted
by, that seems within reach.  See the comment for cost_sort though.
Also, I suppose for incremental sorts we'd want to consider only
the number of newly-sorted columns, but I'm not sure if that info
is readily at hand either.

			regards, tom lane



Commits

  1. Split out tiebreaker comparisons from comparetup_* functions

  2. Add additional regression tests for select_active_windows