Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XMZNw-0000e7-My for pgsql-bugs@arkaria.postgresql.org; Wed, 27 Aug 2014 09:19:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XMZNw-0005Mj-6S for pgsql-bugs@arkaria.postgresql.org; Wed, 27 Aug 2014 09:19:20 +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 1XMZNv-0005Mc-Jc for pgsql-bugs@postgresql.org; Wed, 27 Aug 2014 09:19:19 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XMZNi-0004iW-4Z for pgsql-bugs@postgresql.org; Wed, 27 Aug 2014 09:19:18 +0000 MIME-Version: 1.0 Subject: BUG #11279: unnecessary subplan reduces performance To: pgsql-bugs@postgresql.org From: qiao5034@163.com Date: Wed, 27 Aug 2014 09:18:35 +0000 Message-ID: <20140827091835.2544.2465@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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