index compatible date_trunc in postgres?

Поиск
Список
Период
Сортировка
От Bryce Nesbitt
Тема index compatible date_trunc in postgres?
Дата
Msg-id 494B3545.8030701@obviously.com
обсуждение исходный текст
Ответы Re: index compatible date_trunc in postgres?  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Re: index compatible date_trunc in postgres?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
I've got a legacy app that does 8.3 incompatible date searches like so:
explain select count(*) from contexts where publication_date like '2006%';
explain select count(*) from contexts where publication_date like
'2006-09%';

I've got my choice of refactoring, but all these share the same
sequential scan limitation:
explain select count(*) from contexts where publication_date::text LIKE
'2006%';
explain select count(*) from contexts where
date_trunc('year',publication_date) = '2006-01-01';
explain select count(*) from contexts where extract('year' from
publication_date) = '2006';

Are there any other index compatible methods, other than turning it into
a range search?
explain select count(*) from contexts where publication_date >=
'2006-01-01' and publication_date < '2007-01-01';
explain select count(*) from contexts where publication_date >=
'2006-09-01' and publication_date < '2006-09-31 24:00:00';



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

Предыдущее
От: Steve Crawford
Дата:
Сообщение: Re: Re: How to insert Images(bnp,png,etc) into Postgresql and how to retrive the inserted Imaged using C#.net
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: index compatible date_trunc in postgres?