John,
> I think the key is to get the planner to correctly ballpark the number of
> rows in the date range. If it does, I can't imagine it ever deciding to
> read 1,000,000 rows instead of 1,000 with any sane "cost" setting. I'm
> assuming the defaults are sane :)
The default for random_page_cost is sane, but very conservative; it's pretty
much assuming tables that are bigger than RAM and a single IDE disk. If
your setup is better than that, you can lower it.
For example, in the ideal case (database fits in RAM, fast RAM, CPU, and
random seek on the disk), you can lower it to 1.5. For less ideal
situations, 1.8 to 2.5 is reasonable on high-end hardware.
--
-Josh Berkus
Aglio Database Solutions
San Francisco