explain.depesz.com

PostgreSQL's explain analyze made readable

Result: VI0o

Settings
# exclusive inclusive rows x rows loops node
1. 0.022 2,694.060 ↓ 2.0 2 1

Sort (cost=2,451.60..2,451.61 rows=1 width=436) (actual time=2,694.059..2,694.060 rows=2 loops=1)

  • Sort Key: p.invoice_date DESC
  • Sort Method: quicksort Memory: 26kB
2. 0.013 2,694.038 ↓ 2.0 2 1

Nested Loop (cost=87.82..2,451.59 rows=1 width=436) (actual time=336.293..2,694.038 rows=2 loops=1)

3. 57.666 2,693.999 ↓ 2.0 2 1

Nested Loop Left Join (cost=87.52..2,451.08 rows=1 width=359) (actual time=336.268..2,693.999 rows=2 loops=1)

  • Filter: (cm.client_message_id IS NULL)
  • Rows Removed by Filter: 2,410
4. 1.136 2,049.313 ↓ 1,198.0 2,396 1

Nested Loop (cost=87.10..2,444.10 rows=2 width=359) (actual time=8.026..2,049.313 rows=2,396 loops=1)

5. 102.381 1,854.311 ↓ 409.0 2,454 1

Nested Loop (cost=86.81..2,441.36 rows=6 width=355) (actual time=8.004..1,854.311 rows=2,454 loops=1)

  • Join Filter: (c.client_id = p.client_id)
6. 2.689 773.488 ↓ 217.6 1,741 1

Hash Join (cost=86.39..2,367.96 rows=8 width=108) (actual time=7.955..773.488 rows=1,741 loops=1)

  • Hash Cond: (c.client_id = ea.client_id)
7. 762.883 762.883 ↓ 10.3 1,738 1

Seq Scan on clients c (cost=0.00..2,280.02 rows=168 width=75) (actual time=0.022..762.883 rows=1,738 loops=1)

  • Filter: (einvoice_enable AND (nicepay_account_id IS NOT NULL))
  • Rows Removed by Filter: 31,164
8. 0.330 7.916 ↓ 1.2 1,754 1

Hash (cost=67.48..67.48 rows=1,513 width=33) (actual time=7.916..7.916 rows=1,754 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 134kB
9. 7.586 7.586 ↓ 1.2 1,754 1

Seq Scan on einvoice_accept ea (cost=0.00..67.48 rows=1,513 width=33) (actual time=0.017..7.586 rows=1,754 loops=1)

  • Filter: (accept_complete AND accept_complete)
  • Rows Removed by Filter: 237
10. 978.442 978.442 ↑ 1.0 1 1,741

Index Scan using payments_client_id_index on payments p (cost=0.42..9.16 rows=1 width=263) (actual time=0.327..0.562 rows=1 loops=1,741)

  • Index Cond: (client_id = ea.client_id)
  • Filter: (to_send AND (invoice_date >= '2020-04-23 00:00:00'::timestamp without time zone) AND ((invoice_number)::text !~~* '%/HT/%'::text) AND (company_id = 11) AND (invoice_date > (ea.accepted_at)::date))
  • Rows Removed by Filter: 4
11. 193.866 193.866 ↑ 1.0 1 2,454

Index Scan using dispatch_rows_payment_id_index on dispatch_rows dr (cost=0.29..0.45 rows=1 width=8) (actual time=0.078..0.079 rows=1 loops=2,454)

  • Index Cond: (payment_id = p.payment_id)
  • Filter: ((dispatch_group_id IS NULL) AND (client_message_id IS NULL))
  • Rows Removed by Filter: 0
12. 587.020 587.020 ↑ 1.0 1 2,396

Index Scan using client_messages_external_payment_id_index on client_messages cm (cost=0.42..3.48 rows=1 width=15) (actual time=0.154..0.245 rows=1 loops=2,396)

  • Index Cond: ((p.external_id)::text = (external_payment_id)::text)
  • Filter: ((company_id = 11) AND ((message_type)::text = 'email_new_payment'::text) AND (company_id = p.company_id))
  • Rows Removed by Filter: 0
13. 0.026 0.026 ↑ 1.0 1 2

Index Scan using clients_messages_dispatch_attachments_row_id_idx on dispatch_attachments da (cost=0.29..0.50 rows=1 width=77) (actual time=0.013..0.013 rows=1 loops=2)

  • Index Cond: (dispatch_row_id = dr.dispatch_row_id)
Planning time : 2.357 ms
Execution time : 2,694.263 ms