explain.depesz.com

PostgreSQL's explain analyze made readable

Result: wUzy

Settings
# exclusive inclusive rows x rows loops node
1. 0.001 22.203 ↓ 4.5 9 1

Limit (cost=1,139.86..1,139.86 rows=2 width=10) (actual time=22.202..22.203 rows=9 loops=1)

2. 0.019 22.202 ↓ 4.5 9 1

Sort (cost=1,139.86..1,139.86 rows=2 width=10) (actual time=22.202..22.202 rows=9 loops=1)

  • Sort Key: commands.priority DESC, commands.id
  • Sort Method: quicksort Memory: 25kB
3. 0.002 22.183 ↓ 4.5 9 1

Subquery Scan on commands (cost=1,139.81..1,139.85 rows=2 width=10) (actual time=22.179..22.183 rows=9 loops=1)

4. 0.003 22.181 ↓ 4.5 9 1

Unique (cost=1,139.81..1,139.83 rows=2 width=10) (actual time=22.178..22.181 rows=9 loops=1)

5. 0.003 22.178 ↓ 4.5 9 1

Sort (cost=1,139.81..1,139.82 rows=2 width=10) (actual time=22.178..22.178 rows=9 loops=1)

  • Sort Key: cq.id, cq.priority
  • Sort Method: quicksort Memory: 25kB
6. 0.002 22.175 ↓ 4.5 9 1

Append (cost=17.24..1,139.80 rows=2 width=10) (actual time=22.172..22.175 rows=9 loops=1)

7. 0.000 0.028 ↓ 0.0 0 1

Limit (cost=17.24..17.24 rows=1 width=10) (actual time=0.028..0.028 rows=0 loops=1)

8. 0.002 0.028 ↓ 0.0 0 1

Sort (cost=17.24..17.24 rows=1 width=10) (actual time=0.028..0.028 rows=0 loops=1)

  • Sort Key: cq.priority DESC, cq.id
  • Sort Method: quicksort Memory: 25kB
9. 0.000 0.026 ↓ 0.0 0 1

Nested Loop (cost=9.19..17.23 rows=1 width=10) (actual time=0.026..0.026 rows=0 loops=1)

10. 0.001 0.026 ↓ 0.0 0 1

HashAggregate (cost=8.63..8.64 rows=1 width=8) (actual time=0.026..0.026 rows=0 loops=1)

  • Group Key: min(cq1.id)
11. 0.000 0.025 ↓ 0.0 0 1

GroupAggregate (cost=8.59..8.61 rows=1 width=23) (actual time=0.025..0.025 rows=0 loops=1)

  • Group Key: cq1.target_id
12. 0.003 0.025 ↓ 0.0 0 1

Sort (cost=8.59..8.60 rows=1 width=23) (actual time=0.025..0.025 rows=0 loops=1)

  • Sort Key: cq1.target_id
  • Sort Method: quicksort Memory: 25kB
13. 0.022 0.022 ↓ 0.0 0 1

Index Scan using command_queue_idx1 on command_queue cq1 (cost=0.56..8.58 rows=1 width=23) (actual time=0.022..0.022 rows=0 loops=1)

  • Index Cond: (((status)::text = 'ERROR'::text) AND (to_recalculate = true))
  • Filter: to_recalculate
14. 0.000 0.000 ↓ 0.0 0

Index Scan using command_queue_pkey on command_queue cq (cost=0.56..8.58 rows=1 width=10) (never executed)

  • Index Cond: (id = (min(cq1.id)))
15. 0.001 22.145 ↓ 9.0 9 1

Limit (cost=1,122.53..1,122.54 rows=1 width=10) (actual time=22.143..22.145 rows=9 loops=1)

16. 0.012 22.144 ↓ 9.0 9 1

Sort (cost=1,122.53..1,122.54 rows=1 width=10) (actual time=22.143..22.144 rows=9 loops=1)

  • Sort Key: cq_1.priority DESC, cq_1.id
  • Sort Method: quicksort Memory: 25kB
17. 1.198 22.132 ↓ 9.0 9 1

Nested Loop (cost=1,088.81..1,122.52 rows=1 width=10) (actual time=10.452..22.132 rows=9 loops=1)

  • Join Filter: (cq_1.id = (min(cq2.id)))
  • Rows Removed by Join Filter: 22,618
18. 0.519 9.538 ↓ 11.0 11 1

Nested Loop Anti Join (cost=1.13..30.34 rows=1 width=10) (actual time=0.064..9.538 rows=11 loops=1)

19. 3.328 3.328 ↓ 813.0 813 1

Index Scan using command_queue_status_idx on command_queue cq_1 (cost=0.56..4.59 rows=1 width=25) (actual time=0.022..3.328 rows=813 loops=1)

  • Index Cond: ((status)::text = 'PENDING'::text)
20. 5.691 5.691 ↑ 1.0 1 813

Index Scan using command_queue_idx2 on command_queue cq3 (cost=0.56..13.16 rows=1 width=15) (actual time=0.007..0.007 rows=1 loops=813)

  • Index Cond: (((status)::text = ANY ('{PROCESSING,ERROR}'::text[])) AND ((cq_1.target_id)::text = (target_id)::text))
  • Filter: (NOT to_recalculate)
21. 1.979 11.396 ↓ 10.3 2,057 11

HashAggregate (cost=1,087.68..1,089.68 rows=200 width=8) (actual time=0.889..1.036 rows=2,057 loops=11)

  • Group Key: min(cq2.id)
22. 1.686 9.417 ↑ 2.0 2,057 1

HashAggregate (cost=997.41..1,037.53 rows=4,012 width=23) (actual time=8.969..9.417 rows=2,057 loops=1)

  • Group Key: cq2.target_id
23. 7.731 7.731 ↑ 1.4 2,861 1

Index Scan using command_queue_status_idx on command_queue cq2 (cost=0.56..977.31 rows=4,020 width=23) (actual time=0.018..7.731 rows=2,861 loops=1)

  • Index Cond: ((status)::text = ANY ('{PENDING,ERROR}'::text[]))
Planning time : 0.978 ms
Execution time : 22.312 ms