Re: COPY locking

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: coers(at)intrinsity(dot)com
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: COPY locking
Date: 2001-05-12 20:22:27
Message-ID: 11400.989698947@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have committed some changes into development sources that should
reduce contention overhead when multiple backends are inserting into the
same table. If you're interested in trying it out, you could pull the
latest sources from our CVS server, or try back-patching the changes
into 7.1.*. The relevant changes are in these files:

2001-05-12 15:58 tgl

* src/: backend/access/heap/heapam.c, backend/access/heap/hio.c,
backend/storage/buffer/bufmgr.c, backend/storage/buffer/localbuf.c,
include/storage/bufmgr.h: Modify RelationGetBufferForTuple() so
that we only do lseek and lock when we need to move to a new page;
as long as we can insert the new tuple on the same page as before,
we only need LockBuffer and not the expensive stuff. Also, twiddle
bufmgr interfaces to avoid redundant lseeks in
RelationGetBufferForTuple and BufferAlloc. Successive inserts now
require one lseek per page added, rather than one per tuple with
several additional ones at each page boundary as happened before.
Lock contention when multiple backends are inserting in same table
is also greatly reduced.

2001-05-10 16:38 tgl

* src/: backend/commands/sequence.c,
backend/storage/buffer/bufmgr.c, backend/storage/smgr/md.c,
backend/storage/smgr/mm.c, backend/storage/smgr/smgr.c,
include/storage/smgr.h: Avoid unnecessary lseek() calls by cleanups
in md.c. mdfd_lstbcnt was not being consulted anywhere, so remove
it and remove the _mdnblocks() calls that were used to set it.
Change smgrextend interface to pass in the target block number (ie,
current file length) --- the caller always knows this already,
having already done smgrnblocks(), so it's silly to do it over
again inside mdextend. Net result: extension of a file now takes
one lseek(SEEK_END) and a write(), not three lseeks and a write.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Dederer 2001-05-12 20:48:48 RE: Question on Starting Postgres for the first time
Previous Message Tom Lane 2001-05-12 18:05:44 Re: microsecond log timestamps