summaryrefslogtreecommitdiff
path: root/src/include/access
diff options
context:
space:
mode:
authorTom Lane2010-08-01 02:12:42 +0000
committerTom Lane2010-08-01 02:12:42 +0000
commit0454f131616ecafcc9289da919ab9acdabd0aad7 (patch)
treeb6c3826d75e6da94f6e8ff82dbdf36ee9133d2b7 /src/include/access
parentafc2900ffd988a858aeab896f028a4fee549cbc9 (diff)
Rewrite the rbtree routines so that an RBNode is the first field of the
struct representing a tree entry, rather than being a separately allocated piece of storage. This API is at least as clean as the old one (if not more so --- there were some bizarre choices in there) and it permits a very substantial memory savings, on the order of 2X in ginbulk.c's usage. Also, fix minor memory leaks in code called by ginEntryInsert, in particular in ginInsertValue and entryFillRoot, as well as ginEntryInsert itself. These leaks resulted in the GIN index build context continuing to bloat even after we'd filled it to maintenance_work_mem and started to dump data out to the index. In combination these fixes restore the GIN index build code to honoring the maintenance_work_mem limit about as well as it did in 8.4. Speed seems on par with 8.4 too, maybe even a bit faster, for a non-pathological case in which HEAD was formerly slower. Back-patch to 9.0 so we don't have a performance regression from 8.4.
Diffstat (limited to 'src/include/access')
-rw-r--r--src/include/access/gin.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/include/access/gin.h b/src/include/access/gin.h
index 236c135568c..d584573c5d9 100644
--- a/src/include/access/gin.h
+++ b/src/include/access/gin.h
@@ -4,7 +4,7 @@
*
* Copyright (c) 2006-2010, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/access/gin.h,v 1.39 2010/07/31 00:30:54 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/gin.h,v 1.40 2010/08/01 02:12:42 tgl Exp $
*--------------------------------------------------------------------------
*/
#ifndef GIN_H
@@ -565,6 +565,7 @@ extern Datum ginarrayconsistent(PG_FUNCTION_ARGS);
/* ginbulk.c */
typedef struct EntryAccumulator
{
+ RBNode rbnode;
Datum value;
uint32 length;
uint32 number;
@@ -579,15 +580,14 @@ typedef struct
long allocatedMemory;
uint32 length;
EntryAccumulator *entryallocator;
- ItemPointerData *tmpList;
RBTree *tree;
- RBTreeIterator *iterator;
} BuildAccumulator;
extern void ginInitBA(BuildAccumulator *accum);
extern void ginInsertRecordBA(BuildAccumulator *accum,
ItemPointer heapptr,
OffsetNumber attnum, Datum *entries, int32 nentry);
+extern void ginBeginBAScan(BuildAccumulator *accum);
extern ItemPointerData *ginGetEntry(BuildAccumulator *accum, OffsetNumber *attnum, Datum *entry, uint32 *n);
/* ginfast.c */