Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToGYb-0006iz-9B for pgsql-performance@arkaria.postgresql.org; Thu, 27 Dec 2012 16:43:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1ToGYa-0005ME-LL for pgsql-performance@arkaria.postgresql.org; Thu, 27 Dec 2012 16:43:44 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToGYZ-0005L6-5O for pgsql-performance@postgresql.org; Thu, 27 Dec 2012 16:43:43 +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 1ToGYW-00066n-OY for pgsql-performance@postgresql.org; Thu, 27 Dec 2012 16:43:42 +0000 Received: from [127.0.0.1] (chocolate.ruo3.org [127.0.0.1]) by chocolate.ruo3.org (Postfix) with ESMTP id BEE485606C9 for ; Thu, 27 Dec 2012 16:43:38 +0000 (GMT) Message-ID: <50DC7ABA.5010109@richardneill.org> Date: Thu, 27 Dec 2012 16:43:38 +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 To: PostgreSQL Performance 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> <50D3CAC4.3070800@richardneill.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 On 27/12/12 16:17, Jeff Janes wrote: > > I still think your best bet is to get rid of the partial index and trade > the full one on (parcel_id_code) for one on (parcel_id_code,exit_state). > I think that will be much less fragile than reindexing in a cron job. > So, at the moment, I have 3 indexes: full: parcel_id_code full: exit_state full: parcel_id_code where exit state is null Am I right that when you suggest just a single, joint index (parcel_id_code,exit_state) instead of all 3 of the others, it will allow me to optimally run all of the following? : 1. SELECT * from tbl_tracker WHERE parcel_id_code=22345 AND exit_state IS NULL (this is the one we've been discussing) 2. SELECT * from tbl_tracker where parcel_id_code=44533 3. SELECT * from tbl_tracker where exit_code = 2 (2 and 3 are examples of queries I need to run for other purposes, unrelated to this thread, but which use the other indexes.). Thanks, Richard -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance