pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: qiao5034@163.com
To: pgsql-bugs@postgresql.org
Subject: BUG #11279: unnecessary subplan reduces performance
Date: Wed, 27 Aug 2014 09:18:35 +0000
Message-ID: <20140827091835.2544.2465@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      11279
Logged by:          Mason
Email address:      qiao5034@163.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)




-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



Message-ID: <20140827091835.2544.2465@wrigleys.postgresql.org>
Permalink:  ../20140827091835.2544.2465@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20140827091835.2544.2465@wrigleys.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: qiao5034@163.com
  Subject: Re: BUG #11279: unnecessary subplan reduces performance
  In-Reply-To: <20140827091835.2544.2465@wrigleys.postgresql.org>
  References: <20140827091835.2544.2465@wrigleys.postgresql.org>

* 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