explain.depesz.com

PostgreSQL's explain analyze made readable

Result: WxsO

Settings
# exclusive inclusive rows x rows loops node
1. 0.005 32.913 ↓ 24.0 48 1

Limit (cost=1,139.86..1,139.86 rows=2 width=10) (actual time=32.908..32.913 rows=48 loops=1)

2. 0.009 32.908 ↓ 24.0 48 1

Sort (cost=1,139.86..1,139.86 rows=2 width=10) (actual time=32.906..32.908 rows=48 loops=1)

  • Sort Key: commands.priority DESC, commands.id
  • Sort Method: quicksort Memory: 27kB
3. 0.005 32.899 ↓ 24.0 48 1

Subquery Scan on commands (cost=1,139.81..1,139.85 rows=2 width=10) (actual time=32.885..32.899 rows=48 loops=1)

4. 0.009 32.894 ↓ 24.0 48 1

Unique (cost=1,139.81..1,139.83 rows=2 width=10) (actual time=32.884..32.894 rows=48 loops=1)

5. 0.011 32.885 ↓ 24.0 48 1

Sort (cost=1,139.81..1,139.82 rows=2 width=10) (actual time=32.883..32.885 rows=48 loops=1)

  • Sort Key: cq.id, cq.priority
  • Sort Method: quicksort Memory: 27kB
6. 0.004 32.874 ↓ 24.0 48 1

Append (cost=17.24..1,139.80 rows=2 width=10) (actual time=32.866..32.874 rows=48 loops=1)

7. 0.000 0.026 ↓ 0.0 0 1

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

8. 0.002 0.026 ↓ 0.0 0 1

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

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

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

10. 0.000 0.024 ↓ 0.0 0 1

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

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

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

  • Group Key: cq1.target_id
12. 0.004 0.024 ↓ 0.0 0 1

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

  • Sort Key: cq1.target_id
  • Sort Method: quicksort Memory: 25kB
13. 0.020 0.020 ↓ 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.020..0.020 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.005 32.844 ↓ 48.0 48 1

Limit (cost=1,122.53..1,122.54 rows=1 width=10) (actual time=32.838..32.844 rows=48 loops=1)

16. 0.024 32.839 ↓ 48.0 48 1

Sort (cost=1,122.53..1,122.54 rows=1 width=10) (actual time=32.838..32.839 rows=48 loops=1)

  • Sort Key: cq_1.priority DESC, cq_1.id
  • Sort Method: quicksort Memory: 27kB
17. 5.617 32.815 ↓ 48.0 48 1

Nested Loop (cost=1,088.81..1,122.52 rows=1 width=10) (actual time=9.583..32.815 rows=48 loops=1)

  • Join Filter: (cq_1.id = (min(cq2.id)))
  • Rows Removed by Join Filter: 100368
18. 0.746 10.350 ↓ 48.0 48 1

Nested Loop Anti Join (cost=1.13..30.34 rows=1 width=10) (actual time=0.051..10.350 rows=48 loops=1)

19. 3.752 3.752 ↓ 836.0 836 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.752 rows=836 loops=1)

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

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=836)

  • Index Cond: (((status)::text = ANY ('{PROCESSING,ERROR}'::text[])) AND ((cq_1.target_id)::text = (target_id)::text))
  • Filter: (NOT to_recalculate)
21. 7.874 16.848 ↓ 10.5 2,092 48

HashAggregate (cost=1,087.68..1,089.68 rows=200 width=8) (actual time=0.194..0.351 rows=2,092 loops=48)

  • Group Key: min(cq2.id)
22. 1.433 8.974 ↑ 1.9 2,092 1

HashAggregate (cost=997.41..1,037.53 rows=4,012 width=23) (actual time=8.543..8.974 rows=2,092 loops=1)

  • Group Key: cq2.target_id
23. 7.541 7.541 ↑ 1.4 2,880 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.013..7.541 rows=2,880 loops=1)

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