mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Avoid copying index tuples when building an index.
The previous code, perhaps out of concern for avoid memory leaks, formed the tuple in one memory context and then copied it to another memory context. However, this doesn't appear to be necessary, since index_form_tuple and the functions it calls take precautions against leaking memory. In my testing, building the tuple directly inside the sort context shaves several percent off the index build time. Rearrange things so we do that. Patch by me. Review by Amit Kapila, Tom Lane, Andres Freund.
This commit is contained in:
@@ -336,7 +336,8 @@ typedef struct HSpool HSpool; /* opaque struct in hashsort.c */
|
||||
|
||||
extern HSpool *_h_spoolinit(Relation heap, Relation index, uint32 num_buckets);
|
||||
extern void _h_spooldestroy(HSpool *hspool);
|
||||
extern void _h_spool(IndexTuple itup, HSpool *hspool);
|
||||
extern void _h_spool(HSpool *hspool, ItemPointer self,
|
||||
Datum *values, bool *isnull);
|
||||
extern void _h_indexbuild(HSpool *hspool);
|
||||
|
||||
/* hashutil.c */
|
||||
|
||||
@@ -717,7 +717,8 @@ typedef struct BTSpool BTSpool; /* opaque type known only within nbtsort.c */
|
||||
extern BTSpool *_bt_spoolinit(Relation heap, Relation index,
|
||||
bool isunique, bool isdead);
|
||||
extern void _bt_spooldestroy(BTSpool *btspool);
|
||||
extern void _bt_spool(IndexTuple itup, BTSpool *btspool);
|
||||
extern void _bt_spool(BTSpool *btspool, ItemPointer self,
|
||||
Datum *values, bool *isnull);
|
||||
extern void _bt_leafbuild(BTSpool *btspool, BTSpool *spool2);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user