explain.depesz.com

PostgreSQL's explain analyze made readable

Result: tEtB

Settings
# exclusive inclusive rows x rows loops node
1. 190.632 1,171.805 ↑ 773.0 1,500,960 1

Nested Loop (cost=1,225,650.89..19,184,158.78 rows=1,160,199,296 width=28) (actual time=471.251..1,171.805 rows=1,500,960 loops=1)

2.          

CTE cte_order

3. 51.518 51.518 ↑ 1.3 8,777 1

Index Scan using co_last_update_idx on orders o (cost=0.57..42,009.62 rows=11,303 width=4) (actual time=0.262..51.518 rows=8,777 loops=1)

  • Index Cond: (last_update > (now() - '06:00:00'::interval))
4.          

CTE cte_line

5. 13.453 443.167 ↑ 1,048.6 35,141 1

Nested Loop (cost=254.88..354,522.71 rows=36,849,688 width=4) (actual time=56.620..443.167 rows=35,141 loops=1)

6. 7.094 61.080 ↓ 43.9 8,777 1

HashAggregate (cost=254.32..256.32 rows=200 width=4) (actual time=56.567..61.080 rows=8,777 loops=1)

7. 53.986 53.986 ↑ 1.3 8,777 1

CTE Scan on cte_order (cost=0.00..226.06 rows=11,303 width=4) (actual time=0.265..53.986 rows=8,777 loops=1)

8. 368.634 368.634 ↑ 149.8 4 8,777

Index Scan using order_line_order_id_idx on order_line l (cost=0.57..1,765.34 rows=599 width=8) (actual time=0.020..0.042 rows=4 loops=8,777)

  • Index Cond: (order_id = cte_order.id)
9. 35.170 489.199 ↓ 175.7 35,141 1

HashAggregate (cost=829,117.98..829,119.98 rows=200 width=4) (actual time=471.222..489.199 rows=35,141 loops=1)

10. 454.029 454.029 ↑ 1,048.6 35,141 1

CTE Scan on cte_line (cost=0.00..736,993.76 rows=36,849,688 width=4) (actual time=56.623..454.029 rows=35,141 loops=1)

11. 491.974 491.974 ↑ 937.1 43 35,141

Index Scan using order_line_detail_entity_id_idx on order_line_detail d (cost=0.58..89,389.59 rows=40,294 width=28) (actual time=0.006..0.014 rows=43 loops=35,141)

  • Index Cond: (line_id = cte_line.id)