Re: strange explain in upstream - subplan 1 twice - is it bug?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strange explain in upstream - subplan 1 twice - is it bug?
Date: 2016-07-07 20:28:07
Message-ID: CA+TgmoZ7SyzSXwd-F93E4oS6E1u6z0wFqJdB2VTw80CfKhYNSw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 7, 2016 at 4:13 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> 2016-07-07 21:57 GMT+02:00 Robert Haas <robertmhaas(at)gmail(dot)com>:
>> On Wed, Jun 1, 2016 at 7:29 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
>> wrote:
>> > Hi
>> >
>> > When I tested some queries, I found strange plan
>> >
>> > postgres=# explain analyze select s.nazev, o.nazev, o.pocet_obyvatel
>> > from
>> > (select nazev, array(select id from obce_pocet_obyvatel where okresy.id
>> > =
>> > okres_id order by pocet_obyvatel desc limit 3) as obceids from okresy) s
>> > join obce_pocet_obyvatel o on o.id = ANY(obceids) order by 1, 3 desc;
>>
>> The EXPLAIN plan you posted certainly looks weird, since I wouldn't
>> expect SubPlan 1 to be displayed twice, but I'm wondering if it's a
>> display artifact rather than an actual defect in the plan.
>>
>> Just out of curiosity, what does the output look like with FORMAT JSON
>> or similar?
>
> The test case was wrong, the view "" is necessary
>
> create view obce_pocet_obyvatel as select id, okres_id, nazev, pocet_muzu +
> pocet_zen as pocet_obyvatel from obce;
>
> But the result is same (explain is ok, explain analyze is broken):

Hmm, so it looks like the subplan is somehow getting into it's parents
subPlan list twice. I guess ExecInitExpr must reach that subplan
twice via two different paths, but I'm not quite sure how that's
happening.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bill Moran 2016-07-07 20:56:19 SELECT DISTINCT never uses an index?
Previous Message Robert Haas 2016-07-07 20:23:18 Re: Floating point comparison inconsistencies of the geometric types