X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id AE3AD11F7210 for ; Mon, 24 Apr 2006 19:12:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 07860-07 for ; Mon, 24 Apr 2006 19:11:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id CF60511F6C9A for ; Mon, 24 Apr 2006 19:11:47 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3OMBiNh007023; Mon, 24 Apr 2006 18:11:44 -0400 (EDT) To: "Paul Mackay" cc: pgsql-performance@postgresql.org Subject: Re: Index on function less well cached than "regular" index ? In-reply-to: <786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.com> References: <786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.com> Comments: In-reply-to "Paul Mackay" message dated "Mon, 24 Apr 2006 12:53:29 +0200" Date: Mon, 24 Apr 2006 18:11:44 -0400 Message-ID: <7022.1145916704@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/531 X-Sequence-Number: 18615 "Paul Mackay" 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 plan time. regards, tom lane