explain.depesz.com

PostgreSQL's explain analyze made readable

Result: KxRe : Optimization for: plan #c41R

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.003 11,106.103 ↑ 1.0 1 1

Limit (cost=2.43..768.88 rows=1 width=2,320) (actual time=11,106.102..11,106.103 rows=1 loops=1)

  • Total runtime: 11106.315 ms
2. 10,662.926 11,106.100 ↑ 1.0 1 1

GroupAggregate (cost=2.43..768.88 rows=1 width=2,320) (actual time=11,106.100..11,106.100 rows=1 loops=1)

3. 113.090 443.174 ↓ 3,804.5 380,452 1

Nested Loop Left Join (cost=2.43..767.60 rows=100 width=2,320) (actual time=0.924..443.174 rows=380,452 loops=1)

  • Join Filter: (clients.id = appointment_client_links.client_id)
4. 0.550 140.766 ↓ 113.5 454 1

Nested Loop Left Join (cost=1.14..92.72 rows=4 width=1,361) (actual time=0.509..140.766 rows=454 loops=1)

  • Join Filter: (sp2.client_id = clients.id)
5. 1.164 137.946 ↓ 454.0 454 1

Nested Loop Left Join (cost=0.72..74.80 rows=1 width=694) (actual time=0.500..137.946 rows=454 loops=1)

  • Join Filter: (clients.id = sl.client_id)
6. 0.360 2.398 ↓ 454.0 454 1

Nested Loop Left Join (cost=0.72..16.77 rows=1 width=694) (actual time=0.050..2.398 rows=454 loops=1)

  • Join Filter: (clients.id = sub_clients.client_id)
7. 0.016 0.016 ↑ 1.0 1 1

Index Scan using clients_pkey on clients (cost=0.43..8.45 rows=1 width=467) (actual time=0.014..0.016 rows=1 loops=1)

  • Index Cond: (id = 1700736)
  • Filter: ((NOT demo_entity) AND (NOT deleted))
8. 2.022 2.022 ↓ 454.0 454 1

Index Scan using sub_clients_client_id_idx on sub_clients (cost=0.29..8.31 rows=1 width=231) (actual time=0.031..2.022 rows=454 loops=1)

  • Index Cond: (client_id = 1700736)
9. 134.384 134.384 ↓ 0.0 0 454

Seq Scan on service_packs_links sl (cost=0.00..58.02 rows=1 width=4) (actual time=0.296..0.296 rows=0 loops=454)

  • Filter: (client_id = 1700736)
  • Rows Removed by Filter: 2640
10. 2.270 2.270 ↓ 0.0 0 454

Index Scan using service_packs_client_id_idx on service_packs sp2 (cost=0.42..17.86 rows=4 width=671) (actual time=0.005..0.005 rows=0 loops=454)

  • Index Cond: (client_id = 1700736)
  • Filter: (NOT archived)
11. 33.340 189.318 ↓ 33.5 838 454

Materialize (cost=1.29..673.45 rows=25 width=963) (actual time=0.001..0.417 rows=838 loops=454)

12. 0.877 155.978 ↓ 33.5 838 1

Nested Loop Left Join (cost=1.29..673.32 rows=25 width=963) (actual time=0.410..155.978 rows=838 loops=1)

13. 0.907 82.545 ↓ 29.9 748 1

Nested Loop Left Join (cost=0.86..275.21 rows=25 width=835) (actual time=0.387..82.545 rows=748 loops=1)

14. 15.814 15.814 ↓ 29.9 748 1

Index Scan using appointment_client_links_client_id_idx on appointment_client_links (cost=0.43..63.46 rows=25 width=12) (actual time=0.366..15.814 rows=748 loops=1)

  • Index Cond: (client_id = 1700736)
  • Filter: (account_id > 0)
15. 65.824 65.824 ↑ 1.0 1 748

Index Scan using appointments_pkey on appointments (cost=0.43..8.46 rows=1 width=831) (actual time=0.088..0.088 rows=1 loops=748)

  • Index Cond: (appointment_client_links.appointment_id = id)
  • Filter: ((NOT is_sale) AND (account_id > 0) AND ((status)::text = ANY ('{scheduled,sms_confirmation_sent,cancelled_by_sms,confirmed,in_progress,finished,cancelled,missed}'::text[])))
  • Rows Removed by Filter: 0
16. 72.556 72.556 ↑ 5.0 1 748

Index Scan using appointment_client_service_cost_acl_id on appointment_client_service_cost acsc (cost=0.43..15.87 rows=5 width=136) (actual time=0.095..0.097 rows=1 loops=748)

  • Index Cond: (appointment_client_link_id = appointment_client_links.id)
  • Filter: (account_id > 0)