Re: question about performance

Поиск
Список
Период
Сортировка
От Torsten Zühlsdorff
Тема Re: question about performance
Дата
Msg-id g61eh4$ivj$1@registered.motzarella.org
обсуждение исходный текст
Ответ на Re: question about performance  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Ответы Re: question about performance  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Список pgsql-general
A. Kretschmer schrieb:

>> 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';
>
> Probably the second one, but it depends if you have a propper index.
>
> Other solution: create a functional index based on date_trunc and
> rewrite your where-condition also.

Can you give an example?

Greetings,
Torsten

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

Предыдущее
От: priyaa
Дата:
Сообщение: Problems using Grails with Postgresql
Следующее
От: "Jerry McRae"
Дата:
Сообщение: Calling Python functions with parameters