BUG #11279: unnecessary subplan reduces performance

From: qiao5034(at)163(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #11279: unnecessary subplan reduces performance
Date: 2014-08-27 09:18:35
Message-ID: 20140827091835.2544.2465@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 11279
Logged by: Mason
Email address: qiao5034(at)163(dot)com
PostgreSQL version: 9.2.4
Operating system: linux suse 2.6.32.12-0.7-default
Description:

The following query generates two subplan which is unnecessary.

scripts:

create table a(a1 int, a2 int);
create table b(b1 int, b2 int);
explain
select * from (
select a1, a2,(select SUM(b2) sum_b2 from b where a1 = b1)
from a ) v
where a2 = sum_b2;
QUERY PLAN
---------------------------------------------------------------------
Seq Scan on a (cost=0.00..327949668.86 rows=44331 width=8)
Filter: (a2 = (SubPlan 2))
SubPlan 1
-> Aggregate (cost=36.78..36.79 rows=1 width=4)
-> Seq Scan on b (cost=0.00..36.75 rows=11 width=4)
Filter: (a.a1 = b1)
SubPlan 2
-> Aggregate (cost=36.78..36.79 rows=1 width=4)
-> Seq Scan on b b_1 (cost=0.00..36.75 rows=11 width=4)
Filter: (a.a1 = b1)
(10 rows)

Browse pgsql-bugs by date

  From Date Subject
Next Message Devrim Gündüz 2014-08-27 11:05:43 Re: BUG #11072: rhel-latest-x86_64 missing from repo
Previous Message Eric Malm 2014-08-26 23:53:32 Error with citext extension when upgrading from 9.0.3 to 9.3.5: 'cannot cast type oid[] to oidvector'