Re: Query with date where clause is very slow

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: Query with date where clause is very slow
Дата
Msg-id gnm238$cm3$1@reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на Query with date where clause is very slow  (Mike Christensen <imaudi@comcast.net>)
Список pgsql-general
On 2009-02-20, Mike Christensen <imaudi@comcast.net> wrote:
> Hi all -
>
> I have a fairly simple query:
>
> select * from subscriptions s
> inner join notifications n on n.userid = s.userid
> inner join users u on u.userid = s.userid
> where s.subscriberid='affaa328-5b53-430e-991a-22674ede6faf'
> and n.date > (CURRENT_TIMESTAMP - INTERVAL '14 day')::date;

converting timestamp to date is moderately complex (lots of integer division)
try this instead of (CURRENT_TIMESTAMP - INTERVAL '14 day')::date;

 ('today'::date -14)

indexing notifications on (userid,date) may help significantly too,

bye.

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

Предыдущее
От: Jasen Betts
Дата:
Сообщение: Re: postgres wish list
Следующее
От: Michael Akinde
Дата:
Сообщение: Re: Large object loading stalls