Re: BUG #14107: Major query planner bug regarding subqueries and indices

From: Yaroslav <ladayaroslav(at)yandex(dot)ru>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14107: Major query planner bug regarding subqueries and indices
Date: 2016-04-23 10:22:22
Message-ID: 1461406942121-5900147.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Mathias Kunter 2016-04-23 15:08:16 Re: Re: BUG #14107: Major query planner bug regarding subqueries and indices
Previous Message Kevin Burke 2016-04-23 03:05:06 Re: UPDATE grabs multiple rows when it seems like it should only grab one