explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 8aFf

Settings
# exclusive inclusive rows x rows loops node
1. 0.866 2.656 ↓ 18.0 18 1

WindowAgg (cost=77.92..134.16 rows=1 width=203) (actual time=0.941..2.656 rows=18 loops=1)

2.          

CTE conversations

3. 0.162 0.432 ↓ 3.2 61 1

Nested Loop (cost=0.85..77.01 rows=19 width=16) (actual time=0.033..0.432 rows=61 loops=1)

4. 0.087 0.087 ↓ 3.0 61 1

Index Scan using idx_sms_conversations_complex on sms_conversations sc (cost=0.42..23.79 rows=20 width=16) (actual time=0.017..0.087 rows=61 loops=1)

  • Index Cond: (company_id = 348)
5. 0.183 0.183 ↑ 1.0 1 61

Index Scan using queue_pkey on queue eq_1 (cost=0.43..2.66 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=61)

  • Index Cond: (id = sc.queue_id)
  • Filter: (status_id = ANY ('{1,2,3,4,7,8,11}'::integer[]))
6. 0.041 0.692 ↓ 18.0 18 1

Nested Loop (cost=0.91..51.43 rows=1 width=144) (actual time=0.592..0.692 rows=18 loops=1)

7. 0.075 0.597 ↑ 1.1 18 1

HashAggregate (cost=0.47..0.67 rows=19 width=16) (actual time=0.583..0.597 rows=18 loops=1)

  • Group Key: conversations.phone_id
8. 0.522 0.522 ↓ 3.2 61 1

CTE Scan on conversations (cost=0.00..0.38 rows=19 width=16) (actual time=0.037..0.522 rows=61 loops=1)

9. 0.054 0.054 ↑ 1.0 1 18

Index Scan using queue_pkey on queue eq (cost=0.43..2.66 rows=1 width=136) (actual time=0.003..0.003 rows=1 loops=18)

  • Index Cond: (id = (max(conversations.id)))
  • Filter: ((COALESCE(group_id, 0) <> ALL ('{3,20}'::integer[])) AND (company_id = 348) AND (type_id = 2))
10.          

SubPlan (for WindowAgg)

11. 0.522 0.522 ↑ 1.0 1 18

Index Scan using idx_registered_numbers_company_id on registered_numbers (cost=0.27..2.53 rows=1 width=32) (actual time=0.020..0.029 rows=1 loops=18)

  • Index Cond: (company_id = 348)
  • Filter: ((phone)::text ~* (pmt_get_client_phone_number((eq.phone_account_number)::text, 0))::text)
  • Rows Removed by Filter: 2
12. 0.123 0.576 ↓ 0.0 0 18

Nested Loop (cost=0.86..3.10 rows=1 width=0) (actual time=0.032..0.032 rows=0 loops=18)

13. 0.126 0.270 ↓ 3.0 3 18

HashAggregate (cost=0.43..0.44 rows=1 width=8) (actual time=0.012..0.015 rows=3 loops=18)

  • Group Key: conversations_1.id
14. 0.144 0.144 ↓ 3.0 3 18

CTE Scan on conversations conversations_1 (cost=0.00..0.43 rows=1 width=8) (actual time=0.003..0.008 rows=3 loops=18)

  • Filter: (phone_id = conversations.phone_id)
  • Rows Removed by Filter: 58
15. 0.183 0.183 ↓ 0.0 0 61

Index Scan using queue_pkey on queue (cost=0.43..2.66 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=61)

  • Index Cond: (id = conversations_1.id)
  • Filter: ((status_id = 7) AND (viewed_status_id = 1))
  • Rows Removed by Filter: 1