summaryrefslogtreecommitdiff
path: root/src/include/access
diff options
context:
space:
mode:
authorDavid Rowley2022-11-24 04:21:44 +0000
committerDavid Rowley2022-11-24 04:21:44 +0000
commitd09dbeb9bde6b9faabd30e887eff4493331d6424 (patch)
treef4e543205d960ff8261862aea33d4d21cda7b150 /src/include/access
parentd46ad72f464beafa6d92d60d214412374559e280 (diff)
Speedup hash index builds by skipping needless binary searches
When building hash indexes using the spool method, tuples are added to the index page in hashkey order. Because of this, we can safely skip performing the binary search on the existing tuples on the page to find the location to insert the tuple based on its hashkey value. For this case, we can just always put the tuple at the end of the item array as the tuples will always arrive in hashkey order. Testing has shown that this can improve hash index build speeds by 5-15% with a unique set of integer values. Author: Simon Riggs Reviewed-by: David Rowley Tested-by: David Zhang, Tomas Vondra Discussion: https://postgr.es/m/CANbhV-GBc5JoG0AneUGPZZW3o4OK5LjBGeKe_icpC3R1McrZWQ@mail.gmail.com
Diffstat (limited to 'src/include/access')
-rw-r--r--src/include/access/hash.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/include/access/hash.h b/src/include/access/hash.h
index da372841c4b..02f35e63a70 100644
--- a/src/include/access/hash.h
+++ b/src/include/access/hash.h
@@ -390,9 +390,11 @@ extern void hashadjustmembers(Oid opfamilyoid,
/* private routines */
/* hashinsert.c */
-extern void _hash_doinsert(Relation rel, IndexTuple itup, Relation heapRel);
+extern void _hash_doinsert(Relation rel, IndexTuple itup, Relation heapRel,
+ bool sorted);
extern OffsetNumber _hash_pgaddtup(Relation rel, Buffer buf,
- Size itemsize, IndexTuple itup);
+ Size itemsize, IndexTuple itup,
+ bool appendtup);
extern void _hash_pgaddmultitup(Relation rel, Buffer buf, IndexTuple *itups,
OffsetNumber *itup_offsets, uint16 nitups);