From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | josh(at)agliodbs(dot)com |
Cc: | PgSQL Performance ML <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Suggestions wanted for 7.2.4 query |
Date: | 2003-05-04 04:42:00 |
Message-ID: | 25878.1052023320@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Josh Berkus <josh(at)agliodbs(dot)com> writes:
> SELECT sv_events.*, FALSE AS fuzzy_team FROM sv_events WHERE EXISTS ( SELECT
> event_id FROM event_days
> WHERE event_days.event_id = sv_events.event_id AND (event_day BETWEEN
> ('2003-04-08'::TIMESTAMP WITHOUT TIME ZONE)
> AND ('2003-06-17 23:59'::TIMESTAMP WITHOUT TIME ZONE) ) );
Is event_days.event_id unique? If so, try
SELECT sv_events.*, FALSE AS fuzzy_team FROM sv_events, event_days
WHERE
event_days.event_id = sv_events.event_id AND
(event_days.event_day BETWEEN
('2003-04-08'::TIMESTAMP WITHOUT TIME ZONE)
AND ('2003-06-17 23:59'::TIMESTAMP WITHOUT TIME ZONE) );
This at least gives you some glimmer of a chance that the restriction on
event_day can be used to avoid computing the entire join represented by
sv_events. With the exists() form, there's no chance...
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2003-05-04 16:07:03 | Re: Suggestions wanted for 7.2.4 query |
Previous Message | Christopher Kings-Lynne | 2003-05-04 04:05:42 | Re: NOT IN doesn't use index? (fwd) |