]> granicus.if.org Git - postgresql/commit
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)
commit787eba734be8e1fb8c5fdb101a02e826cccec3e9
tree511dc9dc0fc8e2f04c2e4862eb9e8348ee87396a
parentec6550c6c06ba3a0cf4df31d1016aa8eb8716ddb
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