Really really slow query. What's a better way?

From: Brendan Duddridge <brendan(at)clickspace(dot)com>
To: PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org>
Cc: Tony Copping <tony(at)clickspace(dot)com>
Subject: Really really slow query. What's a better way?
Date: 2006-02-24 06:54:45
Message-ID: 1831440F-F848-471D-ACE9-F84CE9F4E359@clickspace.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi,

We're executing a query that has the following plan and we're
wondering given the size of the data set, what's a better way to
write the query? It's been running since 2pm 2 days ago.

explain DELETE FROM cds.cds_mspecxx WHERE ProdID not in (SELECT
stage.ProdID FROM cds_stage.cds_Catalog stage where stage.countryCode
= 'us') and countryCode = 'us';
QUERY PLAN
------------------------------------------------------------------------
---------------------------
Index Scan using pk_mspecxx on cds_mspecxx
(cost=53360.87..208989078645.48 rows=7377879 width=6)
Index Cond: ((countrycode)::text = 'us'::text)
Filter: (NOT (subplan))
SubPlan
-> Materialize (cost=53360.87..77607.54 rows=1629167 width=12)
-> Seq Scan on cds_catalog stage (cost=0.00..43776.70 rows=1629167
width=12)
Filter: ((countrycode)::text = 'us'::text)
(7 rows)

Thanks,

____________________________________________________________________
Brendan Duddridge | CTO | 403-277-5591 x24 | brendan(at)clickspace(dot)com

ClickSpace Interactive Inc.
Suite L100, 239 - 10th Ave. SE
Calgary, AB T2G 0V9

http://www.clickspace.com

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Christopher Kings-Lynne 2006-02-24 07:06:34 Re: Really really slow query. What's a better way?
Previous Message Tom Lane 2006-02-23 22:46:59 Re: 0ut of Memory Error during Vacuum Analyze and