explain.depesz.com

PostgreSQL's explain analyze made readable

Result: YNwJ

Settings
# exclusive inclusive rows x rows loops node
1. 2,057.126 56,487.801 ↓ 12,128.0 12,128 1

Nested Loop Left Join (cost=10,787.82..35,130.01 rows=1 width=85) (actual time=40.048..56,487.801 rows=12,128 loops=1)

  • Join Filter: ((coir.contract_id = cs.contract_id) AND (cr.import_invoice_row_id = imir.id))
  • Rows Removed by Join Filter: 29450060
  • Filter: (round((imir.item_sum_before_vat - COALESCE((sum(cr.monetary_amount)), '0'::numeric)), 3) <> '0'::numeric)
  • Rows Removed by Filter: 1097
2. 10.603 393.325 ↓ 13,225.0 13,225 1

Nested Loop (cost=1,030.99..24,549.19 rows=1 width=13) (actual time=11.070..393.325 rows=13,225 loops=1)

3. 0.000 316.542 ↓ 6,618.0 13,236 1

Nested Loop (cost=1,030.70..24,548.28 rows=2 width=17) (actual time=10.918..316.542 rows=13,236 loops=1)

  • Join Filter: (coir.item_id = i.division_item_id)
  • Rows Removed by Join Filter: 96071
4. 74.728 107.533 ↓ 1,477.1 109,307 1

Hash Join (cost=1,030.43..24,525.61 rows=74 width=25) (actual time=10.875..107.533 rows=109,307 loops=1)

  • Hash Cond: ((imir.property_id = p.id) AND (date_trunc('month'::text, imir.period_start) = date_trunc('month'::text, coir.valid_from)))
5. 22.106 23.596 ↓ 1.5 20,607 1

Bitmap Heap Scan on import_invoice_row imir (cost=232.06..23,589.79 rows=13,670 width=29) (actual time=1.567..23.596 rows=20,607 loops=1)

  • Recheck Cond: (((cost_owner_type)::text = 'CONTRACT_DIVISIBLE'::text) AND (NOT is_archived) AND ((status_type)::text = 'ACTIVE'::text))
  • Heap Blocks: exact=610
6. 1.490 1.490 ↓ 1.5 20,624 1

Bitmap Index Scan on imir_billable_divisible_row_idx (cost=0.00..228.64 rows=13,670 width=0) (actual time=1.490..1.490 rows=20,624 loops=1)

7. 1.203 9.209 ↑ 1.0 3,757 1

Hash (cost=742.02..742.02 rows=3,757 width=24) (actual time=9.209..9.209 rows=3,757 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 238kB
8. 1.164 8.006 ↑ 1.0 3,757 1

Hash Join (cost=163.18..742.02 rows=3,757 width=24) (actual time=1.622..8.006 rows=3,757 loops=1)

  • Hash Cond: (coir.property_id = p.id)
9. 5.269 5.269 ↑ 1.0 3,757 1

Seq Scan on contract_item_rate coir (cost=0.00..527.18 rows=3,757 width=20) (actual time=0.015..5.269 rows=3,757 loops=1)

  • Filter: (contract_id IS NOT NULL)
  • Rows Removed by Filter: 461
10. 0.465 1.573 ↓ 1.0 3,173 1

Hash (cost=123.68..123.68 rows=3,160 width=4) (actual time=1.573..1.573 rows=3,173 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 144kB
11. 1.108 1.108 ↓ 1.0 3,173 1

Index Only Scan using property_pkey on property p (cost=0.28..123.68 rows=3,160 width=4) (actual time=0.026..1.108 rows=3,173 loops=1)

  • Heap Fetches: 1111
12. 218.614 218.614 ↑ 1.0 1 109,307

Index Scan using item_pkey on item i (cost=0.27..0.29 rows=1 width=8) (actual time=0.001..0.002 rows=1 loops=109,307)

  • Index Cond: (id = imir.item_id)
13. 66.180 66.180 ↑ 1.0 1 13,236

Index Scan using import_invoice_pkey on import_invoice imin (cost=0.29..0.45 rows=1 width=4) (actual time=0.003..0.005 rows=1 loops=13,236)

  • Index Cond: (id = imir.import_invoice_id)
  • Filter: ((status_type)::text = 'APPROVED'::text)
  • Rows Removed by Filter: 0
14. 45,784.950 54,037.350 ↑ 6.2 2,227 13,225

GroupAggregate (cost=9,756.83..10,134.49 rows=13,733 width=20) (actual time=0.003..4.086 rows=2,227 loops=13,225)

  • Group Key: cs.contract_id, cr.import_invoice_row_id
15. 8,232.400 8,252.400 ↑ 1.1 13,035 13,225

Sort (cost=9,756.83..9,791.17 rows=13,733 width=20) (actual time=0.002..0.624 rows=13,035 loops=13,225)

  • Sort Key: cs.contract_id, cr.import_invoice_row_id
  • Sort Method: quicksort Memory: 1020kB
16. 3.675 20.000 ↑ 1.1 13,035 1

Hash Join (cost=992.41..8,813.01 rows=13,733 width=20) (actual time=10.682..20.000 rows=13,035 loops=1)

  • Hash Cond: (cr.cost_sheet_id = cs.id)
17. 5.987 7.128 ↑ 1.1 13,035 1

Bitmap Heap Scan on cost_row cr (cost=220.89..7,852.66 rows=13,733 width=20) (actual time=1.190..7.128 rows=13,035 loops=1)

  • Recheck Cond: ((NOT is_archived) AND ((status_type)::text <> 'DELETED'::text))
  • Heap Blocks: exact=324
18. 1.141 1.141 ↑ 1.1 13,035 1

Bitmap Index Scan on coro_archived_idx (cost=0.00..217.46 rows=13,733 width=0) (actual time=1.141..1.141 rows=13,035 loops=1)

19. 3.495 9.197 ↑ 1.0 20,512 1

Hash (cost=515.12..515.12 rows=20,512 width=8) (actual time=9.197..9.197 rows=20,512 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 1058kB
20. 5.702 5.702 ↑ 1.0 20,512 1

Seq Scan on cost_sheet cs (cost=0.00..515.12 rows=20,512 width=8) (actual time=0.016..5.702 rows=20,512 loops=1)

Planning time : 4.795 ms
Execution time : 56,489.993 ms