| От | Richard Huxton |
|---|---|
| Тема | Re: Queries not always using index on timestamp search |
| Дата | |
| Msg-id | 40DAFBB2.4090202@archonet.com обсуждение исходный текст |
| Ответ на | Queries not always using index on timestamp search (Mike Nolan <nolan@gw.tssi.com>) |
| Список | pgsql-general |
Mike Nolan wrote: > Here are two queries (under 7.4.1): > > 'mytime' is a timestamp field that is indexed. > > select * from mytable where mytime > '2004-06-21' > > select * from mytable where mytime > current_date-3 > > Looking at an explain on these queries, the first one will use the > index and the second one will not, even though 'current_date-3' > produces the same date as the hard-coded one in the first search. > > Is there a way to get the second query to use the index? Probably the simplest is to define a function ago(int) that does the calculation for you. Mark the function STABLE and that should do it. See the archives for more discussion of this. -- Richard Huxton Archonet Ltd
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера