Re: PoC: Partial sort

Alexander Korotkov <aekorotkov@gmail.com>

From: Alexander Korotkov <aekorotkov@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Andreas Karlsson <andreas@proxel.se>, pgsql-hackers <pgsql-hackers@postgresql.org>, Andres Freund <andres@2ndquadrant.com>, Martijn van Oosterhout <kleptog@svana.org>
Date: 2013-12-28T15:51:01Z
Lists: pgsql-hackers

Attachments

On Sat, Dec 28, 2013 at 1:04 PM, David Rowley <dgrowleyml@gmail.com> wrote:

> On Sat, Dec 28, 2013 at 9:28 PM, Alexander Korotkov <aekorotkov@gmail.com>wrote:
>
>>  On Tue, Dec 24, 2013 at 6:02 AM, Andreas Karlsson <andreas@proxel.se>wrote:
>> Attached revision of patch implements partial sort usage in merge joins.
>>
>>
>>
> I'm looking forward to doing a bit of testing on this patch. I think it is
> a really useful feature to get a bit more out of existing indexes.
>
> I was about to test it tonight, but I'm having trouble getting the patch
> to compile... I'm really wondering which compiler you are using as it seems
> you're declaring your variables in some strange places.. See nodeSort.c
> line 101. These variables are declared after there has been an if statement
> in the same scope. That's not valid in C. (The patch did however apply
> without any complaints).
>
> Here's a list of the errors I get when compiling with visual studios on
> windows.
>
> "D:\Postgres\c\pgsql.sln" (default target) (1) ->
> "D:\Postgres\c\postgres.vcxproj" (default target) (2) ->
> (ClCompile target) ->
>   src\backend\executor\nodeSort.c(101): error C2275: 'Sort' : illegal use
> of this type as an expression [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(101): error C2065: 'plannode' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(102): error C2275: 'PlanState' : illegal
> use of this type as an expression [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(102): error C2065: 'outerNode' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(103): error C2275: 'TupleDesc' : illegal
> use of this type as an expression [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(103): error C2146: syntax error :
> missing ';' before identifier 'tupDesc' [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(103): error C2065: 'tupDesc' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(120): error C2065: 'outerNode' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(121): error C2065: 'tupDesc' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(121): error C2065: 'outerNode' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(125): error C2065: 'tupDesc' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(126): error C2065: 'plannode' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(126): error C2223: left of '->numCols'
> must point to struct/union [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(127): error C2065: 'plannode' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(127): error C2223: left of
> '->sortColIdx' must point to struct/union [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(128): error C2065: 'plannode' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(128): error C2223: left of
> '->sortOperators' must point to struct/union
> [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(129): error C2065: 'plannode' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(129): error C2223: left of
> '->collations' must point to struct/union [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(130): error C2065: 'plannode' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(130): error C2223: left of
> '->nullsFirst' must point to struct/union [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(132): error C2198:
> 'tuplesort_begin_heap' : too few arguments for call
> [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(143): error C2065: 'outerNode' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>   src\backend\executor\nodeSort.c(167): error C2065: 'tupDesc' :
> undeclared identifier [D:\Postgres\c\postgres.vcxproj]
>
>     13 Warning(s)
>     24 Error(s)
>

I've compiled it with clang. Yeah, there was mixed declarations. I've
rechecked it with gcc, now it gives no warnings. I didn't try it with
visual studio, but I hope it will be OK.

------
With best regards,
Alexander Korotkov.

Commits

  1. Implement Incremental Sort

  2. Improve memory management for external sorts.