Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 5E52F63275E for ; Fri, 11 Jun 2010 12:32:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 92045-05 for ; Fri, 11 Jun 2010 15:32:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.8]) by mail.postgresql.org (Postfix) with ESMTP id C9920632731 for ; Fri, 11 Jun 2010 12:32:17 -0300 (ADT) Received: from [192.168.1.6] (pool-96-244-14-10.bltmmd.fios.verizon.net [96.244.14.10]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0MeMN5-1OdEwq1tlf-00Q30O; Fri, 11 Jun 2010 17:32:15 +0200 Message-ID: <4C1256FD.6070707@2ndquadrant.com> Date: Fri, 11 Jun 2010 11:32:13 -0400 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Jayadevan M CC: pgsql-performance@postgresql.org Subject: Re: Query about index usage References: <4C119B3E.3090608@squeakycode.net> <4C12050A.5060100@enterprisedb.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX1/GojlMYe4IAECjskdFiuxOmi7UPHlXE4T48ko 2baaLPI8PawCoqQmDgwFJ/cSMaeXacgbxDAT4GChIHDGJoEDuG bxkBxYGv+pKN5vJkvTt4mcjmWR+6LT3 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.001 tagged_above=-10 required=5 tests=BAYES_40=-0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201006/211 X-Sequence-Number: 39067 Jayadevan M wrote: > One query about PostgreSQL's index usage. If I select just one column on > which there is an index (or select only columns on which there is an > index), and the index is used by PostgreSQL, does PostgreSQL avoid table > access if possible? PostgreSQL keeps information about what rows are visible or not in with the row data. It's therefore impossible at this time for it to answer queries just based on what's in an index. Once candidate rows are found using one, the database must then also retrieve the row(s) and do a second check as to whether it's visible to the running transaction or not before returning them to the client. Improving this situation is high up on the list of things to improve in PostgreSQL and the value of it recognized, it just hasn't been built yet. -- Greg Smith 2ndQuadrant US Baltimore, MD PostgreSQL Training, Services and Support greg@2ndQuadrant.com www.2ndQuadrant.us