Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id B04D29FB5C5 for ; Tue, 28 Aug 2007 13:56:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 34259-06 for ; Tue, 28 Aug 2007 13:56:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id EE1DB9FB57A for ; Tue, 28 Aug 2007 13:55:59 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l7SGtwFb029056; Tue, 28 Aug 2007 12:55:58 -0400 (EDT) To: Paul cc: pgsql-performance@postgresql.org Subject: Re: index & Bitmap Heap Scan In-reply-to: <1188290949.29582.9.camel@thory> References: <1188290949.29582.9.camel@thory> Comments: In-reply-to Paul message dated "Tue, 28 Aug 2007 10:49:09 +0200" Date: Tue, 28 Aug 2007 12:55:58 -0400 Message-ID: <29055.1188320158@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/360 X-Sequence-Number: 26490 Paul writes: > Why in the first case, pgsql uses the "better" index and if i search > r_service instead of r_numero pgsql does a "Bitmap Heap scan" first ? Given the difference in the number of rows to be fetched, both plan choices look pretty reasonable to me. If you want to experiment, you can try forcing the other choice in each case (use enable_indexscan and enable_bitmapscan) and see how fast it is, but I suspect the planner got it right. Beware of cache effects when trying two plans in quick succession --- the second one might go faster just because all the data is already swapped in. regards, tom lane