timestamp query doesn't use an index ...

Поиск
Список
Период
Сортировка
От Marc G. Fournier
Тема timestamp query doesn't use an index ...
Дата
Msg-id 20060520223704.T1114@ganymede.hub.org
обсуждение исходный текст
Ответы Re: timestamp query doesn't use an index ...  (Michael Glaesemann <grzm@seespotcode.net>)
Re: timestamp query doesn't use an index ...  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
I'm trying to figure out some way to speed up the following query:
  select ps2.page_id, ps2.template_component_id, max(ps2.start_time)    from page_schedule ps2   where ps2.start_time
attime zone 'MST7MDT' <= '2006-5-17 8:9:18'
 
group by ps2.page_id, ps2.template_component_id

When run through EXPLAIN ANALYZE, it shows:
                                                          QUERY PLAN 

-------------------------------------------------------------------------------------------------------------------------------
HashAggregate (cost=2613.28..2614.17 rows=72 width=16) (actual time=976.629..976.938 rows=128 loops=1)   ->  Seq Scan
onpage_schedule ps2  (cost=0.00..2364.95 rows=33110 width=16) (actual time=0.021..623.363 rows=94798 loops=1)
Filter:(timezone('MST7MDT'::text, start_time) <= '2006-05-17 08:09:18'::timestamp without time zone) Total runtime:
977.224ms
 
(4 rows)

I've tried doing a function index, like:

create index start_time_page_schedule          on page_schedule       using btree ( timezone('MST7MDT'::text,
start_time) );
 

But, same result ... whereas, if I change the <= to just =, the index is 
used, but that is expected ...

Is there some other way I can either write above query *or* do an index, 
such that it will use the index?

thanks ...

----
Marc G. Fournier           Hub.Org Networking Services (http://www.hub.org)
Email . scrappy@hub.org                              MSN . scrappy@hub.org
Yahoo . yscrappy               Skype: hub.org        ICQ . 7615664


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

Предыдущее
От: Ash Grove
Дата:
Сообщение: Re: insert related data into two tables
Следующее
От: Michael Glaesemann
Дата:
Сообщение: Re: timestamp query doesn't use an index ...