diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-03-16 23:15:08 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-03-16 23:15:08 +0000 |
| commit | 787eba734be8e1fb8c5fdb101a02e826cccec3e9 (patch) | |
| tree | 511dc9dc0fc8e2f04c2e4862eb9e8348ee87396a /src/include/utils/tuplesort.h | |
| parent | ec6550c6c06ba3a0cf4df31d1016aa8eb8716ddb (diff) | |
| download | postgresql-787eba734be8e1fb8c5fdb101a02e826cccec3e9.tar.gz | |
When creating a large hash index, pre-sort the index entries by estimated
bucket number, so as to ensure locality of access to the index during the
insertion step. Without this, building an index significantly larger than
available RAM takes a very long time because of thrashing. On the other
hand, sorting is just useless overhead when the index does fit in RAM.
We choose to sort when the initial index size exceeds effective_cache_size.
This is a revised version of work by Tom Raney and Shreya Bhargava.
Diffstat (limited to 'src/include/utils/tuplesort.h')
| -rw-r--r-- | src/include/utils/tuplesort.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h index f552de91db..7bd497092e 100644 --- a/src/include/utils/tuplesort.h +++ b/src/include/utils/tuplesort.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/tuplesort.h,v 1.28 2008/01/01 19:45:59 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/tuplesort.h,v 1.29 2008/03/16 23:15:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -41,16 +41,24 @@ typedef struct Tuplesortstate Tuplesortstate; * rather than forming actual HeapTuples (which'd have to be converted to * MinimalTuples). * - * Yet a third slightly different interface supports sorting bare Datums. + * The IndexTuple case is itself broken into two subcases, one for btree + * indexes and one for hash indexes; the latter variant actually sorts + * the tuples by hash code. The API is the same except for the "begin" + * routine. + * + * Yet another slightly different interface supports sorting bare Datums. */ extern Tuplesortstate *tuplesort_begin_heap(TupleDesc tupDesc, int nkeys, AttrNumber *attNums, Oid *sortOperators, bool *nullsFirstFlags, int workMem, bool randomAccess); -extern Tuplesortstate *tuplesort_begin_index(Relation indexRel, - bool enforceUnique, - int workMem, bool randomAccess); +extern Tuplesortstate *tuplesort_begin_index_btree(Relation indexRel, + bool enforceUnique, + int workMem, bool randomAccess); +extern Tuplesortstate *tuplesort_begin_index_hash(Relation indexRel, + uint32 hash_mask, + int workMem, bool randomAccess); extern Tuplesortstate *tuplesort_begin_datum(Oid datumType, Oid sortOperator, bool nullsFirstFlag, int workMem, bool randomAccess); |
