From 277807bd9eba1645d8dfc9252fa29220c4a83751 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sun, 2 Jul 2006 02:23:23 +0000 Subject: Add FILLFACTOR to CREATE INDEX. ITAGAKI Takahiro --- src/backend/access/gist/gist.c | 17 ++++++++++++----- src/backend/access/gist/gistutil.c | 20 +++++++++++++++++--- src/backend/access/gist/gistvacuum.c | 4 ++-- src/backend/access/gist/gistxlog.c | 4 ++-- 4 files changed, 33 insertions(+), 12 deletions(-) (limited to 'src/backend/access/gist') diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index 39ff702c3d1..4137ab4426f 100644 --- a/src/backend/access/gist/gist.c +++ b/src/backend/access/gist/gist.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.139 2006/06/28 12:00:14 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.140 2006/07/02 02:23:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,6 +44,7 @@ static void gistbuildCallback(Relation index, void *state); static void gistdoinsert(Relation r, IndexTuple itup, + Size freespace, GISTSTATE *GISTstate); static void gistfindleaf(GISTInsertState *state, GISTSTATE *giststate); @@ -197,7 +198,8 @@ gistbuildCallback(Relation index, * you're inserting single tups, but not when you're initializing the * whole index at once. */ - gistdoinsert(index, itup, &buildstate->giststate); + gistdoinsert(index, itup, IndexGetPageFreeSpace(index), + &buildstate->giststate); buildstate->indtuples += 1; MemoryContextSwitchTo(oldCtx); @@ -236,7 +238,7 @@ gistinsert(PG_FUNCTION_ARGS) values, isnull, true /* size is currently bogus */); itup->t_tid = *ht_ctid; - gistdoinsert(r, itup, &giststate); + gistdoinsert(r, itup, 0, &giststate); /* cleanup */ freeGISTstate(&giststate); @@ -253,7 +255,7 @@ gistinsert(PG_FUNCTION_ARGS) * so it does not bother releasing palloc'd allocations. */ static void -gistdoinsert(Relation r, IndexTuple itup, GISTSTATE *giststate) +gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate) { GISTInsertState state; @@ -263,6 +265,7 @@ gistdoinsert(Relation r, IndexTuple itup, GISTSTATE *giststate) state.itup[0] = (IndexTuple) palloc(IndexTupleSize(itup)); memcpy(state.itup[0], itup, IndexTupleSize(itup)); state.ituplen = 1; + state.freespace = freespace; state.r = r; state.key = itup->t_tid; state.needInsertComplete = true; @@ -294,7 +297,11 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate) */ - if (gistnospace(state->stack->page, state->itup, state->ituplen, (is_leaf) ? InvalidOffsetNumber : state->stack->childoffnum)) + /* + * XXX: If we want to change fillfactors between node and leaf, + * fillfactor = (is_leaf ? state->leaf_fillfactor : state->node_fillfactor) + */ + if (gistnospace(state->stack->page, state->itup, state->ituplen, (is_leaf) ? InvalidOffsetNumber : state->stack->childoffnum, state->freespace)) { /* no space for insertion */ IndexTuple *itvec; diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c index 3be4fd31f58..ae1fbc73201 100644 --- a/src/backend/access/gist/gistutil.c +++ b/src/backend/access/gist/gistutil.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.16 2006/06/28 12:00:14 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.17 2006/07/02 02:23:18 momjian Exp $ *------------------------------------------------------------------------- */ #include "postgres.h" @@ -58,9 +58,9 @@ gistfillbuffer(Relation r, Page page, IndexTuple *itup, * Check space for itup vector on page */ bool -gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete) +gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace) { - unsigned int size = 0, deleted = 0; + unsigned int size = freespace, deleted = 0; int i; for (i = 0; i < len; i++) @@ -82,6 +82,7 @@ gistfitpage(IndexTuple *itvec, int len) { for(i=0;i