Commit 712ea250 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

1. Use qsort for first run

2. Limit number of tuples in leftist trees:
	- put one tuple from current tree to disk if limit reached;
	- end run creation if limit reached by nextrun.
3. Avoid mergeruns() if first run is single one!
parent 303f6514
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/lselect.c,v 1.8 1997/09/12 04:08:46 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/lselect.c,v 1.9 1997/09/18 05:37:30 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -26,15 +26,6 @@ ...@@ -26,15 +26,6 @@
#include "utils/psort.h" #include "utils/psort.h"
#include "utils/lselect.h" #include "utils/lselect.h"
#define PUTTUP(TUP, FP) fwrite((char *)TUP, (TUP)->t_len, 1, FP)
/*
* USEMEM - record use of memory
* FREEMEM - record freeing of memory
*/
#define USEMEM(context,AMT) context->sortMem -= (AMT)
#define FREEMEM(context,AMT) context->sortMem += (AMT)
/* /*
* lmerge - merges two leftist trees into one * lmerge - merges two leftist trees into one
* *
...@@ -149,8 +140,7 @@ gettuple(struct leftist ** treep, ...@@ -149,8 +140,7 @@ gettuple(struct leftist ** treep,
else else
*treep = lmerge(tp->lt_left, tp->lt_right, context); *treep = lmerge(tp->lt_left, tp->lt_right, context);
FREEMEM(context, sizeof(struct leftist)); pfree (tp);
FREE(tp);
return (tup); return (tup);
} }
...@@ -173,7 +163,6 @@ puttuple(struct leftist ** treep, ...@@ -173,7 +163,6 @@ puttuple(struct leftist ** treep,
register struct leftist *tp; register struct leftist *tp;
new1 = (struct leftist *) palloc((unsigned) sizeof(struct leftist)); new1 = (struct leftist *) palloc((unsigned) sizeof(struct leftist));
USEMEM(context, sizeof(struct leftist));
new1->lt_dist = 1; new1->lt_dist = 1;
new1->lt_devnum = devnum; new1->lt_devnum = devnum;
new1->lt_tuple = newtuple; new1->lt_tuple = newtuple;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment