Skip to content

Instantly share code, notes, and snippets.

@joewildish
Created November 18, 2021 16:59
Show Gist options
  • Save joewildish/8eb66815d728399687b24647df941746 to your computer and use it in GitHub Desktop.
Save joewildish/8eb66815d728399687b24647df941746 to your computer and use it in GitHub Desktop.
Plan path estimate degradation
Nested Loop Left Join (cost=2.29..348095.52 rows=3 width=93) (actual time=828.619..3368.362 rows=517367 loops=1)
-> Nested Loop (cost=1.86..348094.00 rows=3 width=81) (actual time=828.609..2655.136 rows=517367 loops=1)
Join Filter: (clients.id = order_items.client_id)
-> Nested Loop (cost=1.43..347875.73 rows=400 width=60) (actual time=828.603..1890.900 rows=517367 loops=1)
Join Filter: (clients.id = order_items_1.client_id)
-> Merge Join (cost=1.00..322712.24 rows=50370 width=48) (actual time=828.584..1224.993 rows=517367 loops=1)
Merge Cond: (order_items_2.client_id = clients.id)
-> GroupAggregate (cost=0.85..290718.67 rows=2518498 width=44) (actual time=0.040..1126.298 rows=1856351 loops=1)
Group Key: order_items_2.client_id, order_items_2.order_item_id
-> Merge Left Join (cost=0.85..240348.71 rows=2518498 width=18) (actual time=0.033..535.466 rows=1858076 loops=1)
Merge Cond: ((order_items_2.client_id = discount_allocations.client_id) AND (order_items_2.order_item_id = discount_allocations.order_item_id))
-> Index Only Scan using pk_order_items on order_items order_items_2 (cost=0.43..131145.90 rows=2518498 width=12) (actual time=0.022..150.068 rows=1856352 loops=1)
Heap Fetches: 0
-> Index Scan using pk_discount_allocations on discount_allocations (cost=0.42..89823.14 rows=931889 width=18) (actual time=0.008..110.223 rows=677531 loops=1)
-> Index Only Scan using pk_clients on clients (cost=0.14..8.64 rows=4 width=4) (actual time=0.003..0.011 rows=4 loops=1)
Index Cond: (id = ANY ('{144,145,146,155}'::integer[]))
Heap Fetches: 0
-> Index Only Scan using pk_order_items on order_items order_items_1 (cost=0.43..0.49 rows=1 width=12) (actual time=0.001..0.001 rows=1 loops=517367)
Index Cond: ((client_id = order_items_2.client_id) AND (order_item_id = order_items_2.order_item_id))
Heap Fetches: 0
-> Index Scan using pk_order_items on order_items (cost=0.43..0.53 rows=1 width=29) (actual time=0.001..0.001 rows=1 loops=517367)
Index Cond: ((client_id = order_items_1.client_id) AND (order_item_id = order_items_1.order_item_id))
-> Index Scan using pk_order_item_variants on order_item_variants (cost=0.43..0.51 rows=1 width=20) (actual time=0.001..0.001 rows=1 loops=517367)
Index Cond: ((client_id = order_items_1.client_id) AND (order_item_id = order_items_1.order_item_id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment