Re: Inefficiency in InitIndexFreeSpaceMap

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Inefficiency in InitIndexFreeSpaceMap
Date: 2008-11-06 03:34:55
Message-ID: 491265DF.2000002@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Why is InitIndexFreeSpaceMap coded to test for the FSM file already
> existing? AFAICS it cannot yet exist and it should be an error anyway
> if it does.

Hmm. The FSM file can exist, if the index isn't created anew, but
truncated and rebuilt. However, we normally create a new relfilenode in
that case, so the only place where that actually happens is with a
temporary ON COMMIT DELETE ROWS table. We could instead drop any extra
relforks when the main fork is truncated, and let index_build recreate
the FSM, see attached patch. That approach does seem cleaner to me, but
it's actually even worse from a performance point of view, FWIW, because
instead of just truncating the file, it's unlinked and recreated.

> The smgrexists probe is hardly free, so losing it would be
> good.

Well, it's only done in index build, so I'm not too worried.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
InitIndexFreeSpaceMap-1.patch text/x-diff 2.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message xie jiong 2008-11-06 03:48:41 question about large object
Previous Message Robert Haas 2008-11-06 03:31:40 Re: BufferAccessStrategy for bulk insert