Re: BUG #13528: LATERAL vs. correlated scalar subquery
От | Marko Tiikkaja |
---|---|
Тема | Re: BUG #13528: LATERAL vs. correlated scalar subquery |
Дата | |
Msg-id | 55BA178F.9050503@joh.to обсуждение исходный текст |
Ответ на | Re: BUG #13528: LATERAL vs. correlated scalar subquery (Maxim Boguk <maxim.boguk@gmail.com>) |
Ответы |
Re: BUG #13528: LATERAL vs. correlated scalar subquery
|
Список | pgsql-bugs |
On 7/30/15 1:48 PM, Maxim Boguk wrote: > You could see that the new plan have lower total cost than the old plan > (âcost=1867.28..1873.03 vs âcost=0.00..125498.75). > I think it's primary reason why it been selected (planner could produce the > old plan but new plan wins on the cost basis). I'll have to admit I could've put more time into the original report, but I don't think that's accurate. If I disable hashagg and hashjoin and tune the query to tell the planner that only one row is to be expected, the plan looks like this: =#* explain analyze select u.elem, x.count from (SELECT u.elem FROM unnest(array[1]) u(elem) LIMIT 1) u(elem), lateral (select counts.count from counts where counts.a = u.elem) x; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------- Nested Loop (cost=0.29..4778.86 rows=1 width=12) (actual time=0.060..52.380 rows=1 loops=1) Join Filter: (u.elem = data.a) Rows Removed by Join Filter: 99999 -> Limit (cost=0.00..0.01 rows=1 width=4) (actual time=0.010..0.011 rows=1 loops=1) -> Function Scan on unnest u (cost=0.00..1.00 rows=100 width=4) (actual time=0.009..0.009 rows=1 loops=1) -> GroupAggregate (cost=0.29..4774.33 rows=200 width=4) (actual time=0.047..45.634 rows=100000 loops=1) Group Key: data.a -> Index Only Scan using data_pkey on data (cost=0.29..4298.32 rows=94802 width=4) (actual time=0.042..19.381 rows=100000 loops=1) Heap Fetches: 100000 Planning time: 0.147 ms Execution time: 52.429 ms (11 rows) which to me suggests that the planner just doesn't realize that it can push the condition on counts.a into the view. .m
В списке pgsql-bugs по дате отправления: