Skip site navigation (1) Skip section navigation (2)

Re: Improving the Performance of Full Table Updates

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Gokulakannan Somasundaram <gokul007(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improving the Performance of Full Table Updates
Date: 2007-09-26 19:02:26
Message-ID: 46FAACC2.5090900@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Gokulakannan Somasundaram wrote:
> Hi Tom/ Heikki,
>            Thanks for the suggestion. After profiling i got similar results.
> So i am thinking of a design like this to get the performance improvement.
> 
> a) We can get one page for insert(during update)  and we will hold the write
> lock on it, till the page gets filled. In this way,
> RelationGetBufferForTuple will get called only once for one page of inserts.

The locking actually isn't that expensive once you have the page pinned.
For starters, keep the page pinned over calls to heap_update, and just
relock it instead of calling RelationGetBufferForTuple. Unsurprisingly,
this is not a new idea:
http://archives.postgresql.org/pgsql-patches/2007-05/msg00499.php.

> b) Do you think if we can optimize the XlogInsert in such a way, it will
> write a page instead of writing all the records in the page.  I think we
> need to write a recovery routine for the same. Currently the page gets
> flushed to the WAL, if it gets modified after the checkpoint. So i still
> need to understand those code pieces. But do you think it is wise to
> continue working on this line?

It's going to be very difficult at least. There's a lot of race
conditions lurking if you try to coalesce multiple updates to a single
WAL record.

That said, making XLogInsert faster would help a lot of use cases, not
only full-table udpates. Most of the time is spent calculating the CRC,
but it has some other non-trivial overhead as well. Profiling XLogInsert
in more detail, and figuring out how to make it faster would be very nice.

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

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2007-09-26 19:23:29
Subject: Re: Reducing NUMERIC size for 8.3
Previous:From: Merlin MoncureDate: 2007-09-26 18:01:43
Subject: Re: Reducing NUMERIC size for 8.3

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group