pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Florian Weimer <fweimer@bfk.de>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Large number of open(2) calls with bulk INSERT into empty table
Date: Wed, 30 Nov 2011 12:29:47 -0500
Message-ID: <23238.1322674187@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoYRGO5Wu4_2yzP0-cmx4GBZHqOO4WKiCxT-R3gV6qrt6A@mail.gmail.com>
References: <82ipm51tcd.fsf@mid.bfk.de>
	<CA+TgmoYRGO5Wu4_2yzP0-cmx4GBZHqOO4WKiCxT-R3gV6qrt6A@mail.gmail.com>

Robert Haas <robertmhaas@gmail.com> writes:
> On Sun, Nov 27, 2011 at 10:24 AM, Florian Weimer <fweimer@bfk.de> wrote:
>> I noticed that a bulk INSERT into an empty table (which has been
>> TRUNCATEd in the same transaction, for good measure) results in a
>> curious number of open(2) calls for the FSM resource fork:

> That's kind of unfortunate.  It looks like every time we extend the
> relation, we try to read the free space map to see whether there's a
> block available with free space in it.  But since we never actually
> make any entries in the free space map, the fork never gets created,
> so every attempt to read it involves a system call to see whether it's
> there.

I wonder whether it'd help if we went ahead and created the FSM file,
with length zero, as soon as the relation is made (or maybe when it
first becomes of nonzero length).  That would at least save the failed
open()s.  We'd still be doing lseeks on the FSM file, but those ought
to be cheaper.

A less shaky way to do it would be to just create the first page of the
FSM file immediately, but that would represent an annoying percentage
increase in the disk space needed for small tables.  Or maybe we could
compromise and do that once the rel reaches N pages, for some N.

			regards, tom lane



view thread (17+ messages)  latest in thread

Message-ID: <23238.1322674187@sss.pgh.pa.us>
Permalink:  ../23238.1322674187@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23238.1322674187@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, fweimer@bfk.de
  Subject: Re: Large number of open(2) calls with bulk INSERT into empty table
  In-Reply-To: <23238.1322674187@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox