X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 045C5D774D for ; Sun, 11 Sep 2005 05:06:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66918-07 for ; Sun, 11 Sep 2005 08:06:05 +0000 (GMT) Received: from linuxworld.com.au (unknown [203.34.46.50]) by svr1.postgresql.org (Postfix) with ESMTP id 87A68D7312 for ; Sun, 11 Sep 2005 05:06:03 -0300 (ADT) Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j8B853ho004528; Sun, 11 Sep 2005 18:05:03 +1000 Received: from localhost (swm@localhost) by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id j8B853qC004525; Sun, 11 Sep 2005 18:05:03 +1000 X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs Date: Sun, 11 Sep 2005 18:05:03 +1000 (EST) From: Gavin Sherry X-X-Sender: swm@linuxworld.com.au To: Mark Dilger Cc: pgsql-performance@postgresql.org Subject: Re: performance discrepancy indexing one column versus In-Reply-To: <4323E016.2060606@markdilger.com> Message-ID: References: <4323E016.2060606@markdilger.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.001 required=5 tests=[AWL=0.001] X-Spam-Level: X-Archive-Number: 200509/125 X-Sequence-Number: 14433 On Sun, 11 Sep 2005, Mark Dilger wrote: > All, > > In the psql output below, I would expect the second query to run faster, > because the b-tree index on two columns knows the values of 'b' for any > given value of 'a', and hence does not need to fetch a row from the > actual table. I am not seeing a speed-up, however, so I expect my > understanding of the index mechanism is wrong. Could anyone enlighten > me? A common but incorrect assumption. We must consult the underlying table when we do an index scan so that we can check visibility information. The reason it is stored there in the table is so that we have only one place to check for tuple visibility and therefore avoid race conditions. A brief explanation of this system is described here: http://www.postgresql.org/docs/8.0/static/mvcc.html. and this page shows what information we store in the to do visibility checks: http://www.postgresql.org/docs/8.0/static/storage-page-layout.html Thanks, Gavin