Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TliMt-0007Og-SW for pgsql-performance@arkaria.postgresql.org; Thu, 20 Dec 2012 15:49:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TliMs-0004lP-Q2 for pgsql-performance@arkaria.postgresql.org; Thu, 20 Dec 2012 15:49:06 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TliMr-0004lJ-LK for pgsql-performance@postgresql.org; Thu, 20 Dec 2012 15:49:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TliMq-00040i-Dn for pgsql-performance@postgresql.org; Thu, 20 Dec 2012 15:49:04 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id qBKFn36a012106; Thu, 20 Dec 2012 10:49:03 -0500 (EST) From: Tom Lane To: Jeff Janes cc: Richard Neill , Sergey Konoplev , "pgsql-performance@postgresql.org" Subject: Re: Why does the query planner use two full indexes, when a dedicated partial index exists? In-reply-to: References: <50D22DE2.4090301@richardneill.org> <50D2528E.7000800@richardneill.org> <50D25A59.3060105@richardneill.org> Comments: In-reply-to Jeff Janes message dated "Wed, 19 Dec 2012 21:12:14 -0800" Date: Thu, 20 Dec 2012 10:49:03 -0500 Message-ID: <12105.1356018543@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Jeff Janes writes: > In any case, I can't get it to prefer the full index in 9.1.6 at all. The > partial index wins hands down unless the table is physically clustered by > the parcel_id_code column. In which that case, the partial index wins by > only a little bit. > This is what I did for the table: > create table tbl_tracker as select case when random()<0.001 then 2 else > case when random()< 0.00003 then NULL else 1 end end as exit_state, > (random()*99999)::int as parcel_id_code from generate_series(1,5000000) ; What I did to try to duplicate Richard's situation was to create a test table in which all the exit_state values were NULL, then build the index, then UPDATE all but a small random fraction of the rows to 1, then vacuum. This results in a rather bloated partial index, but I think that's probably what he's got given that every record initially enters the table with NULL exit_state. It would take extremely frequent vacuuming to keep the partial index from accumulating a lot of dead entries. In this scenario, with 9.1, I got overly large estimates for the cost of using the partial index; which matches up with his reports. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance