Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atuiT-0006uy-KR for pgsql-bugs@arkaria.postgresql.org; Sat, 23 Apr 2016 10:23:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1atuiR-0008NH-Ur for pgsql-bugs@arkaria.postgresql.org; Sat, 23 Apr 2016 10:23:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1atuhp-0007gD-CR for pgsql-bugs@postgresql.org; Sat, 23 Apr 2016 10:22:29 +0000 Received: from mbob.nabble.com ([162.253.133.15]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atuhk-0005oz-MS for pgsql-bugs@postgresql.org; Sat, 23 Apr 2016 10:22:28 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mbob.nabble.com (Postfix) with ESMTP id 1718225F589C for ; Sat, 23 Apr 2016 03:08:32 -0700 (PDT) Date: Sat, 23 Apr 2016 03:22:22 -0700 (MST) From: Yaroslav To: pgsql-bugs@postgresql.org Message-ID: <1461406942121-5900147.post@n5.nabble.com> In-Reply-To: <44df2e58-87f5-282c-9871-c735240c55e4@gmail.com> References: <20160421115638.22895.78902@wrigleys.postgresql.org> <69e376c7-6c2c-c96d-2ad6-3734affb59b7@gmail.com> <44df2e58-87f5-282c-9871-c735240c55e4@gmail.com> Subject: Re: BUG #14107: Major query planner bug regarding subqueries and indices MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.2 (-) 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 Hmm... and this is even worse (on the data you provided): EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM book WHERE name = 'Harry Potter' OR EXISTS ( SELECT 1 FROM author WHERE author.id = book.author AND author.name = 'Rowling' ); Seq Scan on book (cost=0.00..832685.00 rows=50000 width=41) (actual time=35.848..35.848 rows=0 loops=1) Filter: (((name)::text = 'Harry Potter'::text) OR (alternatives: SubPlan 1 or hashed SubPlan 2)) Rows Removed by Filter: 100000 Buffers: shared hit=937 SubPlan 1 -> Index Scan using author_name_index on author (cost=0.29..8.30 rows=1 width=0) (never executed) Index Cond: ((name)::text = 'Rowling'::text) Filter: (id = book.author) SubPlan 2 -> Index Scan using author_name_index on author author_1 (cost=0.29..8.30 rows=1 width=4) (actual time=0.027..0.027 rows=0 loops=1) Index Cond: ((name)::text = 'Rowling'::text) Buffers: shared hit=2 Planning time: 0.268 ms Execution time: 35.923 ms ----- WBR, Yaroslav Schekin. -- View this message in context: http://postgresql.nabble.com/BUG-14107-Major-query-planner-bug-regarding-subqueries-and-indices-tp5899873p5900147.html Sent from the PostgreSQL - bugs mailing list archive at Nabble.com. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs