Re: query with timestamp not using index

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: query with timestamp not using index
Дата
Msg-id 19907.1101939413@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: query with timestamp not using index  (Brian Hirt <bhirt@mobygames.com>)
Список pgsql-performance
Brian Hirt <bhirt@mobygames.com> writes:
> it's more like:

> declare
>     foo_date date;
> begin
>     select some_date into foo_date from some_table where something = something_else;
>     select blah from redir_log where redir_timestamp >= foo_date::timestamp without time zone at time zone 'GMT';
>     etc / etc / etc

Ah.  In that case you're going to have trouble anyway with the planner
having no clue what the effective value of the comparison expression is,
because it'll certainly not be able to fold the plpgsql variable to a
constant.  I agree with the other person who suggested faking it out
by adding a dummy other-side-of-the-range constraint, perhaps
    AND redir_timestamp <= now()
(or whatever upper bound is okay for your purposes).  This should coax
it into using an indexscan.

            regards, tom lane

В списке pgsql-performance по дате отправления:

Предыдущее
От: Brian Hirt
Дата:
Сообщение: Re: query with timestamp not using index
Следующее
От: Josh Berkus
Дата:
Сообщение: Alternatives to Dell?