Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XqRIC-0006zf-2f for pgsql-sql@arkaria.postgresql.org; Mon, 17 Nov 2014 18:44:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XqRIB-0007FV-Jl for pgsql-sql@arkaria.postgresql.org; Mon, 17 Nov 2014 18:44:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XqRIA-0007FP-TT for pgsql-sql@postgresql.org; Mon, 17 Nov 2014 18:44:51 +0000 Received: from [162.253.133.43] (helo=mwork.nabble.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XqRI7-000263-Oy for pgsql-sql@postgresql.org; Mon, 17 Nov 2014 18:44:49 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mwork.nabble.com (Postfix) with ESMTP id 69BA6A4AE47 for ; Mon, 17 Nov 2014 10:44:47 -0800 (PST) Date: Mon, 17 Nov 2014 11:44:46 -0700 (MST) From: David G Johnston To: pgsql-sql@postgresql.org Message-ID: <1416249886486-5827275.post@n5.nabble.com> In-Reply-To: <546A3FBA.9020901@gmail.com> References: <546A3FBA.9020901@gmail.com> Subject: Re: slow sub-query problem MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 162.253.133.43 (failed) X-Pg-Spam-Score: 1.9 (+) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Tim Dudgeon wrote > All relevant columns are indexed and using PostgreSQL 9.4. > Any clues how to re-write it to avoid the slow sub-query. Try using an actual join instead of a subquery. You will have to provide aliases and then setup the where clause appropriately. I am reading the query correctly in that the repeated reference to 643413 is redundant? The lack of a defined natural primary key makes blind reasoning difficult. David J. -- View this message in context: http://postgresql.nabble.com/slow-sub-query-problem-tp5827273p5827275.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql