Re: [PATCH] Teach planner to further optimize sort in distinct

2023-01-20 Thread Ankit Kumar Pandey
On 20/01/23 06:07, David Rowley wrote: Looking at the patch, you've not added any additional tests. If the existing tests are all passing then that just tells me that either the code is not functioning as intended or we have no tests that look at the EXPLAIN output which can make use of

Re: [PATCH] Teach planner to further optimize sort in distinct

2023-01-19 Thread David Rowley
On Fri, 20 Jan 2023 at 08:26, Ankit Kumar Pandey wrote: > > On 19/01/23 18:49, David Rowley wrote: > > You can just switch to using that function in > > create_final_distinct_paths(). You'll need to consider if the query is > > a DISTINCT ON query and not try the unordered version of the function

Re: [PATCH] Teach planner to further optimize sort in distinct

2023-01-19 Thread Ankit Kumar Pandey
On 19/01/23 18:49, David Rowley wrote: I think you should write a function like: bool pathkeys_count_contained_in_unordered(List *keys1, List *keys2, List **reorderedkeys, int *n_common) which works very similarly to pathkeys> _count_contained_in, but populates *reorderedkeys so it

Re: [PATCH] Teach planner to further optimize sort in distinct

2023-01-19 Thread David Rowley
On Wed, 18 Jan 2023 at 08:27, Ankit Kumar Pandey wrote: > There is bit confusion in wording here: > > "returns a List of pathkeys > which are in keys1 but not in keys2 and NIL if keys2 has a pathkey > that does not exist as a pathkey in keys1." > > You mean extract common keys without ordering

[PATCH] Teach planner to further optimize sort in distinct

2023-01-17 Thread Ankit Kumar Pandey
Hi, this is extension of `teach planner to evaluate multiple windows in the optimal order` work applied to distinct operation. Based on discussions before