X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A0747D1B437 for ; Mon, 26 Apr 2004 16:16:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 06849-01 for ; Mon, 26 Apr 2004 16:16:29 -0300 (ADT) Received: from uno.mnl.com (uno.mnl.com [63.97.246.49]) by svr1.postgresql.org (Postfix) with SMTP id A0112D1B520 for ; Mon, 26 Apr 2004 16:16:27 -0300 (ADT) Received: (qmail 47297 invoked by uid 1000); 26 Apr 2004 19:16:28 -0000 Message-ID: <20040426191628.47296.qmail@uno.mnl.com> References: <20040423222121.12061.qmail@uno.mnl.com> <20040426115215.R11044@megazone.bigpanda.com> In-Reply-To: <20040426115215.R11044@megazone.bigpanda.com> From: brad-pgperf@duttonbros.com To: Stephan Szabo , pgsql-performance@postgresql.org Subject: Re: index usage Date: Mon, 26 Apr 2004 12:16:28 -0700 Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200404/449 X-Sequence-Number: 6749 When checking an index in postgres the original table has to be checked for each result to find if the index entry is still valid? In which case you can't blindly scan the whole index and assume the data is good. I was used to Oracle behavior where the index is up to date so it can do the scan without hitting the original table. Does this sound correct to anyone? Thanks, Brad Stephan Szabo writes: > On Fri, 23 Apr 2004 brad-pgperf@duttonbros.com wrote: > >> I have a query which I think should be using an index all of the time but >> postgres only uses the index part of the time. The index >> (ticket_crm_map_crm_id_suppid) has the where clause column (crm_id) listed >> first followed by the selected column (support_person_id). Wouldn't the >> most efficient plan be to scan the index each time because the only columns >> needed are in the index? Below is the table, 2 queries showing the > > Not necessarily. The rows in the actual file still need to be checked to > see if they're visible to the select and if it's expected that the entire > file (or a reasonable % of the pages anyway) will need to be loaded using > the index isn't necessarily a win. >