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

slow delete...

From: Jessica Richard <rjessil(at)yahoo(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: slow delete...
Date: 2008-07-04 00:47:49
Message-ID: (view raw or flat)
Lists: pgsql-admin
I have a table with 29K rows total and I need to delete about 80K out of it.

I have a b-tree index on column cola (varchar(255) ) for my where clause to use.

my "select count(*) from test where cola = 'abc' runs very fast,
but my actual "delete from test where cola = 'abc';" takes forever, never can finish and I haven't figured why....

In my explain output, what is that "Bitmap Heap Scan on table"? is it a table scan? is my index being used?

does delete work? to delete 80K rows that meet my condition, does
Postgres find them all and delete them all together or one at a time?

by the way, there is a foreign key on another table that references the primary key col0 on table test.

Could some one help me out here?

Thanks a lot,

testdb=# select count(*) from test;
 295793  --total 295,793 rows
(1 row)

Time: 155.079 ms

testdb=# select count(*) from test where cola = 'abc';
 80998  - need to delete 80,988 rows
(1 row)

testdb=# explain delete from test where cola = 'abc';
                                             QUERY PLAN                                             
 Bitmap Heap Scan on test  (cost=2110.49..10491.57 rows=79766 width=6)
   Recheck Cond: ((cola)::text = 'abc'::text)
   ->  Bitmap Index Scan on test_cola_idx  (cost=0.00..2090.55 rows=79766 width=0)
         Index Cond: ((cola)::text = 'abc'::text)
(4 rows)



pgsql-admin by date

Next:From: Julius TuskenisDate: 2008-07-04 06:41:42
Subject: Re: changing sequence in serial field
Previous:From: Scott MarloweDate: 2008-07-04 00:38:14
Subject: Re: Recourse Usage

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