| От | Alan Hodgson |
|---|---|
| Тема | Re: question about performance |
| Дата | |
| Msg-id | 200807201140.59161@hal.medialogik.com обсуждение исходный текст |
| Ответ на | question about performance (Robert Urban <urban@unix-beratung.de>) |
| Список | pgsql-general |
On Sunday 20 July 2008, Robert Urban <urban@unix-beratung.de> wrote: > Hi PostgreSQLer, > > if I have a table, the_table, with a DATE field, i'll call it 'day', and > I'd like to find all rows whos day falls within a given month, which of > the following methods is faster/costs less: > > 1. > > SELECT * FROM the_table WHERE day LIKE '2008-01-%'; > > 2. > > SELECT * FROM the_table > WHERE ( day BETWEEN '$month_begin' AND '$month_end' ); > > # where $month_begin is '2008-01-01' and $month_end is '2008-01-31'; 2. Particularly if you have an index on the day field. Doing text operations on date fields is not conducive to performance. -- Alan
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера