Re: Forcing filter/join order?
| От | Tom Lane |
|---|---|
| Тема | Re: Forcing filter/join order? |
| Дата | |
| Msg-id | 28948.1077167299@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Forcing filter/join order? (Josh Berkus <josh@agliodbs.com>) |
| Ответы |
Re: Forcing filter/join order?
Re: Forcing filter/join order? |
| Список | pgsql-performance |
Josh Berkus <josh@agliodbs.com> writes:
> Knowing that events are never more than one month long for this
> application, I can do:
> "WHERE event.event_date >= (begin_date - '1 month) AND event.event_date <=
> end_date"
> ... which works because I have a child table which has event information by
> day:
Uh, why do you need the child table? Seems like the correct incantation
given an assumption about maximum duration is
event_date <= 'end-date' AND (event_date + duration) >= 'start-date'
AND event_date >= 'start-date' - 'max-duration'
The last clause is redundant with the one involving the duration field,
but it provides a lower bound for the index scan on event_date. The
only index you really need here is one on event_date, but possibly one
on (event_date, (event_date + duration)) would be marginally faster.
regards, tom lane
В списке pgsql-performance по дате отправления: