Re: PostgreSQL 8.2.5 slow performance on INSERT on Linux

From: "Beyers Cronje" <bcronje(at)gmail(dot)com>
To: "Greg Smith" <gsmith(at)gregsmith(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: PostgreSQL 8.2.5 slow performance on INSERT on Linux
Date: 2007-12-02 23:32:21
Message-ID: 329bff5c0712021532r2f65369dkeb8d09ca45f97002@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

>
> Your development system is probably running inexpensive IDE disks that
> cache writes, while the test server is not caching. If you loop over
> single inserts, PostgreSQL's default configuration will do a physical
> commit to disk after every one of them, which limits performance to how
> fast the disk spins. If your server has 15K RPM drives, a single client
> can commit at most 250 transactions per second to disk, which means 10,000
> inserts done one at a time must take at least 40 seconds no matter how
> fast the server is.
>
> There's a rambling discussion of this topic at
> http://www.westnet.com/~gsmith/content/postgresql/TuningPGWAL.htm<http://www.westnet.com/%7Egsmith/content/postgresql/TuningPGWAL.htm>that
> should fill in some background here.

This is exactly what is happening. Thank you for the above link, the article
was very informative.

If you use COPY instead of INSERT, that bypasses the WAL and you don't see
> this. Also, if you adjust your loop to do multiple inserts as a single
> transaction, that will change the behavior here as well.

I will give COPY a go and see how it performs. For testing we specifically
only did one insert per transaction, we will obviously optimize the actual
application to do multiple insert per transaction where-ever possible.

Kind regards

Beyers Cronje

PS Thank you for the quick responses Greg and Pavel. It is always
encouraging starting off with a new product and seeing there are people
passionate about it.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Michael Glaesemann 2007-12-03 00:28:15 EXPLAIN ANALYZE time calculations
Previous Message Mark Kirkwood 2007-12-02 23:13:07 Re: Dealing with big tables