explain.depesz.com

PostgreSQL's explain analyze made readable

Result: a9fvX

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Limit (cost=1,228.51..1,228.51 rows=1 width=3,829) (actual rows= loops=)

2. 0.000 0.000 ↓ 0.0

Sort (cost=1,228.51..1,228.51 rows=2 width=3,829) (actual rows= loops=)

  • Sort Key: cq.priority DESC, cq.id
3. 0.000 0.000 ↓ 0.0

Unique (cost=1,228.34..1,228.48 rows=2 width=3,829) (actual rows= loops=)

4. 0.000 0.000 ↓ 0.0

Sort (cost=1,228.34..1,228.35 rows=2 width=3,829) (actual rows= loops=)

  • Sort Key: cq.id, cq.created_by, cq.creation_date, cq.modification_date, cq.modified_by, cq.uuid, cq.batch_actions_group_id, cq.class_name, cq.created_date, cq.error_counter, cq.error_message, cq.invoked_date, cq.priority, cq.processed_date, cq.serialized_command, cq.status, cq.target_id, cq.to_recalculate, cq.version, cq.message_id, cq.message_status, cq.session_id, cq.sent_at, cq.code, cq.message, cq.answered_message_id
5. 0.000 0.000 ↓ 0.0

Append (cost=17.24..1,228.33 rows=2 width=3,829) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Limit (cost=17.24..17.24 rows=1 width=739) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Sort (cost=17.24..17.24 rows=1 width=739) (actual rows= loops=)

  • Sort Key: cq.priority DESC, cq.id
8. 0.000 0.000 ↓ 0.0

Nested Loop (cost=9.19..17.23 rows=1 width=739) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

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

  • Group Key: min(cq1.id)
10. 0.000 0.000 ↓ 0.0

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

  • Group Key: cq1.target_id
11. 0.000 0.000 ↓ 0.0

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

  • Sort Key: cq1.target_id
12. 0.000 0.000 ↓ 0.0

Index Scan using command_queue_status_to_recalculate_idx on command_queue cq1 (cost=0.56..8.58 rows=1 width=23) (actual rows= loops=)

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

Index Scan using command_queue_pkey on command_queue cq (cost=0.56..8.58 rows=1 width=739) (actual rows= loops=)

  • Index Cond: (id = (min(cq1.id)))
14. 0.000 0.000 ↓ 0.0

Limit (cost=1,211.06..1,211.07 rows=1 width=739) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Sort (cost=1,211.06..1,211.07 rows=1 width=739) (actual rows= loops=)

  • Sort Key: cq_1.priority DESC, cq_1.id
16. 0.000 0.000 ↓ 0.0

Nested Loop Anti Join (cost=1,194.49..1,211.05 rows=1 width=739) (actual rows= loops=)

17. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1,078.30..1,086.82 rows=1 width=739) (actual rows= loops=)

  • Join Filter: (cq_1.id = (min(cq2.id)))
18. 0.000 0.000 ↓ 0.0

Index Scan using command_queue_status_idx on command_queue cq_1 (cost=0.56..4.59 rows=1 width=739) (actual rows= loops=)

  • Index Cond: ((status)::text = 'PENDING'::text)
19. 0.000 0.000 ↓ 0.0

HashAggregate (cost=1,077.73..1,079.73 rows=200 width=8) (actual rows= loops=)

  • Group Key: min(cq2.id)
20. 0.000 0.000 ↓ 0.0

HashAggregate (cost=991.00..1,029.55 rows=3,855 width=23) (actual rows= loops=)

  • Group Key: cq2.target_id
21. 0.000 0.000 ↓ 0.0

Index Scan using command_queue_status_idx on command_queue cq2 (cost=0.56..971.68 rows=3,863 width=23) (actual rows= loops=)

  • Index Cond: ((status)::text = ANY ('{PENDING,ERROR}'::text[]))
22. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on command_queue cq3 (cost=116.19..120.21 rows=1 width=15) (actual rows= loops=)

  • Recheck Cond: (((cq_1.target_id)::text = (target_id)::text) AND ((status)::text = ANY ('{PROCESSING,ERROR}'::text[])))
  • Filter: (NOT to_recalculate)
23. 0.000 0.000 ↓ 0.0

BitmapAnd (cost=116.19..116.19 rows=1 width=0) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on command_queue_target_id_idx (cost=0.00..4.87 rows=40 width=0) (actual rows= loops=)

  • Index Cond: ((cq_1.target_id)::text = (target_id)::text)
25. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on command_queue_status_idx (cost=0.00..110.11 rows=3,863 width=0) (actual rows= loops=)

  • Index Cond: ((status)::text = ANY ('{PROCESSING,ERROR}'::text[]))