Skip to content

Commit cdd5178

Browse files
committed
Extend the MinimalTuple concept to tuplesort.c, thereby reducing the
per-tuple space overhead for sorts in memory. I chose to replace the previous patch that tried to write out the bare minimum amount of data when sorting on disk; instead, just dump the MinimalTuples as-is. This wastes 3 to 10 bytes per tuple depending on architecture and null-bitmap length, but the simplification in the writetup/readtup routines seems worth it.
1 parent e99507e commit cdd5178

File tree

4 files changed

+139
-152
lines changed

4 files changed

+139
-152
lines changed

src/backend/access/nbtree/nbtsort.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
* Portions Copyright (c) 1994, Regents of the University of California
5757
*
5858
* IDENTIFICATION
59-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.101 2006/05/08 00:00:10 tgl Exp $
59+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.102 2006/06/27 16:53:02 tgl Exp $
6060
*
6161
*-------------------------------------------------------------------------
6262
*/
@@ -179,7 +179,7 @@ _bt_spooldestroy(BTSpool *btspool)
179179
void
180180
_bt_spool(IndexTuple itup, BTSpool *btspool)
181181
{
182-
tuplesort_puttuple(btspool->sortstate, (void *) itup);
182+
tuplesort_putindextuple(btspool->sortstate, itup);
183183
}
184184

185185
/*

src/backend/executor/nodeSort.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/nodeSort.c,v 1.56 2006/03/05 15:58:26 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeSort.c,v 1.57 2006/06/27 16:53:02 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -41,9 +41,7 @@ ExecSort(SortState *node)
4141
EState *estate;
4242
ScanDirection dir;
4343
Tuplesortstate *tuplesortstate;
44-
HeapTuple heapTuple;
4544
TupleTableSlot *slot;
46-
bool should_free;
4745

4846
/*
4947
* get state info from node
@@ -103,8 +101,7 @@ ExecSort(SortState *node)
103101
if (TupIsNull(slot))
104102
break;
105103

106-
tuplesort_puttuple(tuplesortstate,
107-
(void *) ExecFetchSlotTuple(slot));
104+
tuplesort_puttupleslot(tuplesortstate, slot);
108105
}
109106

110107
/*
@@ -131,15 +128,11 @@ ExecSort(SortState *node)
131128
* Get the first or next tuple from tuplesort. Returns NULL if no more
132129
* tuples.
133130
*/
134-
heapTuple = tuplesort_getheaptuple(tuplesortstate,
135-
ScanDirectionIsForward(dir),
136-
&should_free);
137-
138131
slot = node->ss.ps.ps_ResultTupleSlot;
139-
if (heapTuple)
140-
return ExecStoreTuple(heapTuple, slot, InvalidBuffer, should_free);
141-
else
142-
return ExecClearTuple(slot);
132+
(void) tuplesort_gettupleslot(tuplesortstate,
133+
ScanDirectionIsForward(dir),
134+
slot);
135+
return slot;
143136
}
144137

145138
/* ----------------------------------------------------------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy