"Paul Mackay" <mackaypaul(at)gmail(dot)com> writes:
> EXPLAIN shows that an index scan is used by the planner. A query returning
> the maximum 200 number of records takes around 20 ms. What is surprising is
> that the same query executed several times takes practically the same time,
> as if the result was not cached.
> Could the problem be that an index on a function result is not cached or
> less well cached ?
I can't see how that would be. The index machinery has no idea what
it's indexing, and the kernel disk cache even less.
Perhaps the majority of the runtime is going somewhere else, like the
initial evaluation of the function value to compare against? Or maybe
you've found some inefficiency in the planner's handling of function
indexes. Try comparing EXPLAIN ANALYZE output for the two cases to see
if the discrepancy exists during query runtime, or if it's upstream at
regards, tom lane
In response to
pgsql-performance by date
|Next:||From: Sriram Dandapani||Date: 2006-04-24 22:45:14|
|Subject: ip address data type|
|Previous:||From: Jim C. Nasby||Date: 2006-04-24 21:00:18|
|Subject: Re: GROUP BY Vs. Sub SELECT|