Thom Brown <thom@linux.com> writes:
> I've created a test table containing 21 million random dates and
> times, but I get wildly different results when I introduce a
> functional index then ANALYSE again, even though it doesn't use the
> index:
As Peter said, the existence of the index causes ANALYZE to gather stats
about the expression, which will affect rowcount estimates whether or
not the planner chooses to use the index.
> And as a side note, how come it's impossible to get the planner to use
> an index-only scan to satisfy the query (disabling sequential and
> regular index scans)?
Implementation restriction - we don't yet have a way to match index-only
scans to expressions.
regards, tom lane