explain.depesz.com

PostgreSQL's explain analyze made readable

Result: kHRs

Settings
# exclusive inclusive rows x rows loops node
1. 0.007 493.942 ↓ 50.0 100 1

Limit (cost=1,139.82..1,139.82 rows=2 width=10) (actual time=493.932..493.942 rows=100 loops=1)

2. 0.028 493.935 ↓ 50.0 100 1

Sort (cost=1,139.82..1,139.82 rows=2 width=10) (actual time=493.930..493.935 rows=100 loops=1)

  • Sort Key: commands.priority DESC, commands.id
  • Sort Method: quicksort Memory: 29kB
3. 0.007 493.907 ↓ 50.0 100 1

Subquery Scan on commands (cost=1,139.77..1,139.81 rows=2 width=10) (actual time=493.884..493.907 rows=100 loops=1)

4. 0.013 493.900 ↓ 50.0 100 1

Unique (cost=1,139.77..1,139.79 rows=2 width=10) (actual time=493.883..493.900 rows=100 loops=1)

5. 0.016 493.887 ↓ 50.0 100 1

Sort (cost=1,139.77..1,139.78 rows=2 width=10) (actual time=493.883..493.887 rows=100 loops=1)

  • Sort Key: cq.id, cq.priority
  • Sort Method: quicksort Memory: 29kB
6. 0.009 493.871 ↓ 50.0 100 1

Append (cost=17.24..1,139.76 rows=2 width=10) (actual time=493.850..493.871 rows=100 loops=1)

7. 0.001 0.134 ↓ 0.0 0 1

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

8. 0.001 0.133 ↓ 0.0 0 1

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

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

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

10. 0.001 0.132 ↓ 0.0 0 1

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

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

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

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

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

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

Index Scan using command_queue_idx on command_queue cq1 (cost=0.56..8.58 rows=1 width=23) (actual time=0.128..0.128 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.010 493.728 ↓ 100.0 100 1

Limit (cost=1,122.49..1,122.50 rows=1 width=10) (actual time=493.715..493.728 rows=100 loops=1)

16. 0.457 493.718 ↓ 100.0 100 1

Sort (cost=1,122.49..1,122.50 rows=1 width=10) (actual time=493.714..493.718 rows=100 loops=1)

  • Sort Key: cq_1.priority DESC, cq_1.id
  • Sort Method: top-N heapsort Memory: 29kB
17. 154.699 493.261 ↓ 390.0 390 1

Nested Loop (cost=1,088.77..1,122.48 rows=1 width=10) (actual time=23.681..493.261 rows=390 loops=1)

  • Join Filter: (cq_1.id = (min(cq2.id)))
  • Rows Removed by Join Filter: 2424914
18. 8.179 90.006 ↓ 538.0 538 1

Nested Loop Anti Join (cost=1.13..30.34 rows=1 width=10) (actual time=0.063..90.006 rows=538 loops=1)

19. 13.117 13.117 ↓ 6,871.0 6,871 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.025..13.117 rows=6,871 loops=1)

  • Index Cond: ((status)::text = 'PENDING'::text)
20. 68.710 68.710 ↑ 1.0 1 6,871

Index Scan using command_queue_status_target_id_idx on command_queue cq3 (cost=0.56..13.16 rows=1 width=15) (actual time=0.010..0.010 rows=1 loops=6,871)

  • Index Cond: (((status)::text = ANY ('{PROCESSING,ERROR}'::text[])) AND ((cq_1.target_id)::text = (target_id)::text))
  • Filter: (NOT to_recalculate)
21. 226.365 248.556 ↓ 22.5 4,508 538

HashAggregate (cost=1,087.64..1,089.64 rows=200 width=8) (actual time=0.044..0.462 rows=4,508 loops=538)

  • Group Key: min(cq2.id)
22. 5.500 22.191 ↓ 1.1 4,508 1

HashAggregate (cost=997.39..1,037.50 rows=4,011 width=23) (actual time=20.922..22.191 rows=4,508 loops=1)

  • Group Key: cq2.target_id
23. 16.691 16.691 ↓ 2.7 10,989 1

Index Scan using command_queue_status_idx on command_queue cq2 (cost=0.56..977.30 rows=4,019 width=23) (actual time=0.010..16.691 rows=10,989 loops=1)

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