Re: Delete query takes exorbitant amount of time

From: Karim A Nassar <Karim(dot)Nassar(at)NAU(dot)EDU>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Karim A Nassar <Karim(dot)Nassar(at)NAU(dot)EDU>, Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Delete query takes exorbitant amount of time
Date: 2005-03-28 20:03:12
Message-ID: Pine.SOL.4.21.0503281231580.1035-100000@coruscant.cet.nau.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> Well, based upon the evidence so far, the Optimizer got it right:

Agreed. So, this means that the answer to my original question is "that
delete gonna take a long time"?

Seems that there is still something wrong. From what I can tell from
everyones questions, the FK constraint on measurement is causing multiple
seq scans for each value deleted from int_sensor_meas_type. However, when
deleting a single value, the FK check should use the index, so my ~190
deletes *should* be fast, no?

> IndexScan, value=1 elapsed= 29ms cost=883881

190 * 29ms is much less than 40 minutes. What am I missing here?

> Karim,
> Please do:
>
> select id_int_sensor_meas_type, count(*)
> from measurement
> group by id_int_sensor_meas_type
> order by count(*) desc;

id_int_sensor_meas_type | count
-------------------------+--------
31 | 509478
30 | 509478
206 | 509478
205 | 509478
204 | 509478
40 | 509478
39 | 509478
197 | 509478
35 | 509478
34 | 509478
33 | 509478
32 | 509478
41 | 509477

This sample dataset has 13 measurements from a weather station over 3
years, hence the even distribution.

Continued thanks,
--
Karim Nassar
Department of Computer Science
Box 15600, College of Engineering and Natural Sciences
Northern Arizona University, Flagstaff, Arizona 86011
Office: (928) 523-5868 -=- Mobile: (928) 699-9221

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Greg Stark 2005-03-28 20:09:29 Re: which dual-CPU hardware/OS is fastest for PostgreSQL?
Previous Message Josh Berkus 2005-03-28 19:51:17 Re: Query Optimizer Failure / Possible Bug