From: | Ulrich Wisser <ulrich(dot)wisser(at)relevanttraffic(dot)se> |
---|---|
To: | Dan Harris <fbsd(at)drivefaster(dot)net> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Query tuning help |
Date: | 2005-05-11 12:47:31 |
Message-ID: | 4281FEE3.6080506@relevanttraffic.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Hi Dan,
I tried to understand your query, but I couldn't get my understanding of
the query and your description in sync.
Why do you use sub selects? Wouldn't a simple "recordtext like '%RED%'"
do the trick too?
You combine all your where conditions with and. To me this looks like
you get only rows with RED and CORVETTE.
From your description I would rewrite the query as
explain analyze
select distinct
em.incidentid,
ea.recordtext as retdata,
eg.long,
eg.lat
from
ea join em using(incidentid) join eg using(incidentid)
where
em.entrydate >= '2005-1-1 00:00'::date
and em.entrydate <= '2005-5-9 00:00'::date
and ( recordtext like '%RED%' or recordtext like '%CORVETTE%' )
order by em.entrydate
That should give you all rows containing one of the words.
Does it work?
Is is faster? Is it fast enough?
Ulrich
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-05-11 13:27:57 | Re: Partitioning / Clustering |
Previous Message | Christopher Kings-Lynne | 2005-05-11 09:13:43 | Re: Partitioning / Clustering |