Re: [SQL] indexes using datetime

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] indexes using datetime
Дата
Msg-id 9681.935887600@sss.pgh.pa.us
обсуждение исходный текст
Ответ на indexes using datetime  (Michael Richards <miker@scifair.acadiau.ca>)
Ответы Re: [SQL] indexes using datetime  (Herouth Maoz <herouth@oumail.openu.ac.il>)
Список pgsql-sql
Michael Richards <miker@scifair.acadiau.ca> writes:
> explain select * from logins where logintime>'now'::datetime-'40
> days'::timespan;
> NOTICE:  QUERY PLAN:
> Seq Scan on logins  (cost=5839.78 rows=44958 width=44)

> Very bad query plan :(

Yah.  It's got nothing to do with datetime though.  Problem is that the
system can only make indexscans work with WHERE clauses of the form
"field op constant" (for "op"s related to the sort ordering of the
index of course).  Your righthand side is not a constant.

Eventually, maybe for 6.6 or 6.7, we will have the smarts in place to
reduce constant expressions to simple constants during preprocessing of
a query.  For now, you are going to have to structure your application to
precompute the value that's going to be compared against index entries.
        regards, tom lane


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

Предыдущее
От: Michael Richards
Дата:
Сообщение: entries in pg_shadow
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] entries in pg_shadow