Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TliHT-0007KA-Jy for pgsql-performance@arkaria.postgresql.org; Thu, 20 Dec 2012 15:43:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TliHS-0003V2-JT for pgsql-performance@arkaria.postgresql.org; Thu, 20 Dec 2012 15:43:30 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TliHR-0003Uw-F8 for pgsql-performance@postgresql.org; Thu, 20 Dec 2012 15:43:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TliHQ-0003w9-2J for pgsql-performance@postgresql.org; Thu, 20 Dec 2012 15:43:28 +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 qBKFhQKo011998; Thu, 20 Dec 2012 10:43:27 -0500 (EST) From: Tom Lane To: Richard Neill cc: "pgsql-performance@postgresql.org" Subject: Re: Why does the query planner use two full indexes, when a dedicated partial index exists? In-reply-to: <50D2A8BA.2070801@richardneill.org> References: <50D22DE2.4090301@richardneill.org> <50D2528E.7000800@richardneill.org> <50D25A59.3060105@richardneill.org> <50D2A8BA.2070801@richardneill.org> Comments: In-reply-to Richard Neill message dated "Thu, 20 Dec 2012 05:57:14 +0000" Date: Thu, 20 Dec 2012 10:43:26 -0500 Message-ID: <11997.1356018206@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 Richard Neill writes: > Also, I wonder whether it matters which order the indexes are created in? IIRC, if the estimated costs of using two different indexes come out the same (to within 1% or so), then the planner keeps the first-generated path, which will result in preferring the index with smaller OID. This effect doesn't apply to your problem query though, since we can see from the drop-experiments that the estimated costs are quite a bit different. A more likely explanation if you see some effect that looks like order dependency is that the more recently created index has accumulated less bloat, and thus has a perfectly justifiable cost advantage. 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