pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Pierre C <lists@peufeu.com>
Cc: pgsql-performance@postgresql.org, Jarrod Chesney <jarrod.chesney@gmail.com>
Subject: Re: Delete performance
Date: Wed, 01 Jun 2011 09:40:52 +0800
Message-ID: <4DE598A4.1080100@postnewspapers.com.au> (raw)
In-Reply-To: <op.vwdb1pv8eorkce@apollo13>
References: <6940CBA1-BB1C-4030-B425-2DE9135CEAE3@gmail.com>
	<op.vwdb1pv8eorkce@apollo13>

On 1/06/2011 7:11 AM, Pierre C wrote:
>> If i run 30,000 prepared "DELETE FROM xxx WHERE "ID" = ?" commands it
>> takes close to 10 minutes.
>
> Do you run those in a single transaction or do you use one transaction
> per DELETE ?
>
> In the latter case, postgres will ensure each transaction is commited to
> disk, at each commit. Since this involves waiting for the physical I/O
> to happen, it is slow. If you do it 30.000 times, it will be 30.000
> times slow.

Not only that, but if you're doing it via some application the app has 
to wait for Pg to respond before it can send the next query. This adds 
even more delay, as do all the processor switches between Pg and your 
application.

If you really must issue individual DELETE commands one-by-one, I 
*think* you can use synchronous_commit=off or

  SET LOCAL synchronous_commit TO OFF;

See:

http://www.postgresql.org/docs/current/static/runtime-config-wal.html


-- 
Craig Ringer

Tech-related writing at http://soapyfrogs.blogspot.com/



view thread (7+ messages)  latest in thread

Message-ID: <4DE598A4.1080100@postnewspapers.com.au>
Permalink:  ../4DE598A4.1080100@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4DE598A4.1080100@postnewspapers.com.au

 · 

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-performance@postgresql.org
  Cc: craig@postnewspapers.com.au, lists@peufeu.com, jarrod.chesney@gmail.com
  Subject: Re: Delete performance
  In-Reply-To: <4DE598A4.1080100@postnewspapers.com.au>

* 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