Re: Slow Queries with OR's?

From: Mr Mat psql-mail <psql-mail(at)freeuk(dot)com>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Slow Queries with OR's?
Date: 2003-05-02 08:54:19
Message-ID: E19BWJ9-000CTS-00@buckaroo.freeuk.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom - Thanks for your help - it's invaluable!

I have now gone back to my original query shown below:
I set EXPLAIN ANALYZE running on it over 12 hours ago and its still
going! (Yesterdays EXPLAIN ANALYZE took tens of minutes)
So I have included just the ouput from EXPLAIN.

SELECT msg_id, from_line, col_date FROM news_messages WHERE msg_id IN(
SELECT msg_id FROM news_msg_id_ng_id_link WHERE ng_id IN(
SELECT ng_id FROM news_ng_genre_link WHERE genre_id in (3,6)
)
)

QUERY PLAN
------------------------------------------------------------------------
--------------------------
Seq Scan on news_messages (cost=0.00..298471193171502.50 rows=1962232
width=90)
Filter: (subplan)
SubPlan
-> Materialize (cost=76054021.22..76054021.22 rows=4027010 width=44)
-> Seq Scan on news_msg_id_ng_id_link (cost=0.00..76054021.22 rows=
4027010 width=44)
Filter: (subplan)
SubPlan
-> Seq Scan on news_ng_genre_link (cost=0.00..18.84 rows=170 width=8)

Filter: ((genre_id = 3) OR (genre_id = 6))

Any suggestions?
Regards,
The ever thankful.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Manfred Koizar 2003-05-02 10:34:54 Re: fixed size columns
Previous Message Mark Kirkwood 2003-05-02 08:07:58 Re: qsort (was Re: Solaris)