Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TlZ35-00078E-GV for pgsql-performance@arkaria.postgresql.org; Thu, 20 Dec 2012 05:52:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TlZ34-0000yC-KE for pgsql-performance@arkaria.postgresql.org; Thu, 20 Dec 2012 05:52:02 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TlZ33-0000y6-HP for pgsql-performance@postgresql.org; Thu, 20 Dec 2012 05:52:01 +0000 Received: from www.ruo3.org ([87.194.171.29] helo=chocolate.ruo3.org) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TlZ32-0003N0-2S for pgsql-performance@postgresql.org; Thu, 20 Dec 2012 05:52:00 +0000 Received: from [127.0.0.1] (chocolate.ruo3.org [127.0.0.1]) by chocolate.ruo3.org (Postfix) with ESMTP id A1DAB560998 for ; Thu, 20 Dec 2012 05:51:57 +0000 (GMT) Message-ID: <50D2A77D.10809@richardneill.org> Date: Thu, 20 Dec 2012 05:51:57 +0000 From: Richard Neill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 CC: pgsql-performance@postgresql.org Subject: Re: Why does the query planner use two full indexes, when a dedicated partial index exists? References: <50D22DE2.4090301@richardneill.org> <28778.1355972790@sss.pgh.pa.us> In-Reply-To: <28778.1355972790@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.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 Dear Tom, Thanks very much for your advice. >> A psql session is below. This shows that, if I force the planner to use >> the partial index, by dropping the others, then it's fast. But as soon >> as I put the full indexes back (which I need for other queries), the >> query planner chooses them instead, and is slow. > > [ experiments with a similar test case ... ] I think the reason why the > planner is overestimating the cost of using the partial index is that > 9.1 and earlier fail to account for the partial-index predicate when > estimating the number of index rows that will be visited. Because the > partial-index predicate is so highly selective in this case, that > results in a significant overestimate of how much of the index will be > traversed. I think that seems likely to me. I'll try out 9.2 and see if it helps. As it's a production server, I have to wait for some downtime, probably Friday night before I can find out - will report back. Best wishes, Richard -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance