Re: Allow DISTINCT to use Incremental Sort

2023-01-10 Thread David Rowley
On Tue, 10 Jan 2023 at 16:07, Richard Guo wrote: > Sorry I didn't make myself clear. I mean currently on HEAD in planner.c > from line 4847 to line 4857, we have the code to make sure we always use > the more rigorous clause for explicit-sort case. I think this code is > not necessary, because

Re: Allow DISTINCT to use Incremental Sort

2023-01-09 Thread Richard Guo
On Tue, Jan 10, 2023 at 10:14 AM David Rowley wrote: > > /* For explicit-sort case, always use the more rigorous clause */ > > if (list_length(root->distinct_pathkeys) < > > list_length(root->sort_pathkeys)) > > { > > needed_pathkeys =

Re: Allow DISTINCT to use Incremental Sort

2023-01-09 Thread David Rowley
Thanks for having a look at this. On Tue, 10 Jan 2023 at 02:28, Richard Guo wrote: > +1 for the changes. A minor comment is that previously on HEAD for > SELECT DISTINCT case, if we have to do an explicit full sort atop the > cheapest path, we try to make sure to always use the more rigorous >

Re: Allow DISTINCT to use Incremental Sort

2023-01-09 Thread Richard Guo
On Sat, Jan 7, 2023 at 5:47 PM David Rowley wrote: > While working on the regression tests added in a14a58329, I noticed > that DISTINCT does not make use of Incremental Sort. It'll only ever > do full sorts on the cheapest input path or make use of a path that's > already got the required

Allow DISTINCT to use Incremental Sort

2023-01-07 Thread David Rowley
While working on the regression tests added in a14a58329, I noticed that DISTINCT does not make use of Incremental Sort. It'll only ever do full sorts on the cheapest input path or make use of a path that's already got the required pathkeys. Also, I see that create_final_distinct_paths() is a