| От | Michael Fuhr |
|---|---|
| Тема | Re: Checking = with timestamp field is slow |
| Дата | |
| Msg-id | 20041105174534.GA685@winnie.fuhr.org обсуждение исходный текст |
| Ответ на | Re: Checking = with timestamp field is slow (Christopher Browne <cbbrowne@acm.org>) |
| Список | pgsql-performance |
On Fri, Nov 05, 2004 at 07:47:54AM -0500, Christopher Browne wrote:
>
> How about changing the criterion to:
>
> where today between '2004-11-05' and '2004-11-06';
>
> That ought to make use of the index on "today".
Yes it should, but it'll also return records that have a "today"
value of '2004-11-06 00:00:00' since "x BETWEEN y AND z" is equivalent
to "x >= y AND x <= z". Try this instead:
WHERE today >= '2004-11-05' AND today < '2004-11-06'
In another post I suggested creating an index on DATE(today). The
above query should make that unnecessary, although in 8.0 such an
index would be used in queries like this:
WHERE today IN ('2004-09-01', '2004-10-01', '2004-11-01');
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера