Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XjZ65-0002tE-76 for pgsql-general@arkaria.postgresql.org; Wed, 29 Oct 2014 19:39:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XjZ64-00010r-NE for pgsql-general@arkaria.postgresql.org; Wed, 29 Oct 2014 19:39:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XjZ63-00010k-AE for pgsql-general@postgresql.org; Wed, 29 Oct 2014 19:39:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XjZ60-00054T-50 for pgsql-general@postgresql.org; Wed, 29 Oct 2014 19:39:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s9TJdgrS030938; Wed, 29 Oct 2014 15:39:42 -0400 From: Tom Lane To: Jorge Arevalo cc: David Johnston , "pgsql-general@postgresql.org" Subject: Re: Query optimization In-reply-to: References: <1414547659900-5824746.post@n5.nabble.com> <29612.1414608798@sss.pgh.pa.us> Comments: In-reply-to Jorge Arevalo message dated "Wed, 29 Oct 2014 20:14:01 +0100" Date: Wed, 29 Oct 2014 15:39:42 -0400 Message-ID: <30937.1414611582@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Jorge Arevalo writes: >> On Wed, Oct 29, 2014 at 11:53 AM, Tom Lane wrote: >>> I'm also a bit confused as to why the planner is saying that the (SELECT >>> ARRAY(...)) bit is an InitPlan and not a SubPlan. That implies that >>> "field7" in the innermost WHERE clause is not a reference to table1 but a >>> reference to table2. Is that really what you meant? IOW, are you sure >>> this query is performing the right calculation in the first place? > Yes, for each row of table1, table2 is being scanned, to find all the > entries that satisfy table1.field7 = table2.f3. You might think that's what it's doing, but the plan shape says otherwise. An array of 2537787 entries is being formed *once* and then referenced at each row of table1. I'd take another look and see if "field7" isn't a column name that exists in both tables. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general