When creating a large hash index, pre-sort the index entries by estimated
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 16 Mar 2008 23:15:08 +0000 (23:15 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 16 Mar 2008 23:15:08 +0000 (23:15 +0000)
commit907f1c9888654666bd1488b74049854510a59430
tree83f0064c7ad0ee8c837b39851a16d60cbbe1329e
parent77ad0ba6ad782c10e8010395711b8fcd3f7f9a61
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.
src/backend/access/hash/Makefile
src/backend/access/hash/hash.c
src/backend/access/hash/hashpage.c
src/backend/access/hash/hashsort.c [new file with mode: 0644]
src/backend/access/nbtree/nbtsort.c
src/backend/utils/sort/tuplesort.c
src/include/access/hash.h
src/include/utils/tuplesort.h