Re: timestamp query doesn't use an index ...
От | Tom Lane |
---|---|
Тема | Re: timestamp query doesn't use an index ... |
Дата | |
Msg-id | 5287.1148225462@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | timestamp query doesn't use an index ... ("Marc G. Fournier" <scrappy@postgresql.org>) |
Ответы |
Re: timestamp query doesn't use an index ...
|
Список | pgsql-sql |
"Marc G. Fournier" <scrappy@postgresql.org> writes: > 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 at time zone 'MST7MDT' <= '2006-5-17 8:9:18' > group by ps2.page_id, ps2.template_component_id > Is there some other way I can either write above query *or* do an index, > such that it will use the index? One-sided inequalities frequently *shouldn't* use an index, because they're retrieving too much of the table. Are you sure this is fetching only a small fraction of the table? Are you using PG 8.1 (8.1 would be likely to try to use a bitmap indexscan for this)? You could experiment with enable_seqscan = off to see if the planner is actually wrong about its choice. If so, reducing random_page_cost might be the best permanent solution. regards, tom lane
В списке pgsql-sql по дате отправления: