From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marc G. Fournier <scrappy@postgresql.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: timestamp query doesn't use an index ...
Date: Sun, 21 May 2006 11:31:02 -0400
Message-ID: <5287.1148225462@sss.pgh.pa.us> (raw)
In-Reply-To: <20060520223704.T1114@ganymede.hub.org>
References: <20060520223704.T1114@ganymede.hub.org>
"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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, scrappy@postgresql.org
Subject: Re: timestamp query doesn't use an index ...
In-Reply-To: <5287.1148225462@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox