Re: [PERFORM] Delete performance

2011-06-01 Thread Jarrod Chesney

On 01/06/2011, at 11:45 AM, Jarrod Chesney wrote:

 I'm executing 30,000 single delete statements in one transaction.
 
 At this point i'm looking into combining the multiple deletes into one 
 statement and breaking my big transaction into smaller ones of about 100 
 deletes or so.
 
 On 01/06/2011, at 11:40 AM, Craig Ringer wrote:
 
 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/
 

Apologies for top posting, Sorry.
-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


[PERFORM] Delete performance

2011-05-30 Thread Jarrod Chesney
Hi All
My database uses joined table inheritance and my server version is 9.0

Version string  PostgreSQL 9.0rc1 on x86_64-pc-linux-gnu, compiled by GCC 
x86_64-pc-linux-gnu-gcc (Gentoo 4.4.4-r1 p1.1, pie-0.4.5) 4.4.4, 64-bit   

I have about 120,000 records in the table that everything else inherits from, 
if i truncate-cascaded this table it happens almost instantly. If i run 30,000 
prepared DELETE FROM xxx WHERE ID = ? commands it takes close to 10 minutes.

My foreign keys to the base table are all set with ON DELETE CASCADE. I've 
looked though all the feilds that relate to the ID in the base table and 
created btree indexes for them.

Can anyone outline what I need to verify/do to ensure i'm getting the best 
performance for my deletes?

Regards, Jarrod Chesney 
-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance