Re: pattern matching with dates?

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: pattern matching with dates?
Дата
Msg-id 4D273ACE.5070508@archonet.com
обсуждение исходный текст
Ответ на Re: pattern matching with dates?  (pasman pasmański <pasman.p@gmail.com>)
Список pgsql-sql
On 07/01/11 14:15, pasman pasmański wrote:
> Sorry, but this examples not use index.

Looks like it does here (oh, and please try to post your replies at the 
bottom of the message)

> On 1/7/11, Susanne Ebrecht<susanne@2ndquadrant.com>  wrote:

>> The more proper way is:
>>    SELECT * from tab WHERE EXTRACT(YEAR FROM log_date) = 2011 and
>> EXTRACT(MONTH FROM log_date) = 1;

CREATE TABLE d_table (d date);
INSERT INTO d_table SELECT '2001-01-01'::date + generate_series(1,9999);
CREATE INDEX d_extract_idx ON d_table ( extract('day' FROM d) );
EXPLAIN ANALYSE SELECT * FROM d_table WHERE extract('day' FROM d) = 3;

That ends up doing a bitmap index scan for me.

Of course, it's entirely possible an index on year+month returns too 
many rows to be useful.

--   Richard Huxton  Archonet Ltd


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

Предыдущее
От: pasman pasmański
Дата:
Сообщение: Re: pattern matching with dates?
Следующее
От: Russell Galyon
Дата:
Сообщение: Re: return records with more than one occurrences