pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jorge Arevalo <jorgearevalo@libregis.org>
Cc: David Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Query optimization
Date: Wed, 29 Oct 2014 15:39:42 -0400
Message-ID: <30937.1414611582@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMhtMNMA2_usWDiDCo89qJfb4iW43rOYTLjdqh7qS60w9=2ZpQ@mail.gmail.com>
References: <CAMhtMNNTDmcTXZ8yjyxtaXvaYYaW04_tnqXRqajH=Kz1Dswmtw@mail.gmail.com>
	<1414547659900-5824746.post@n5.nabble.com>
	<CAMhtMNOoGMB3fSMdjjYf2ukq=DmhDp4eHsnM8H_cdfATCjTRyQ@mail.gmail.com>
	<29612.1414608798@sss.pgh.pa.us>
	<CAKFQuwa8teEGExc0XQWmqo3Dsrs9Rov_=Ykg5iuKSY+hGZC5iA@mail.gmail.com>
	<CAMhtMNMA2_usWDiDCo89qJfb4iW43rOYTLjdqh7qS60w9=2ZpQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>

Jorge Arevalo <jorgearevalo@libregis.org> writes:
>> On Wed, Oct 29, 2014 at 11:53 AM, Tom Lane <tgl@sss.pgh.pa.us> 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



view thread (48+ messages)  latest in thread

Message-ID: <30937.1414611582@sss.pgh.pa.us>
Permalink:  ../30937.1414611582@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/30937.1414611582@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jorgearevalo@libregis.org, david.g.johnston@gmail.com
  Subject: Re: Query optimization
  In-Reply-To: <30937.1414611582@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox