explain.depesz.com

PostgreSQL's explain analyze made readable

Result: W1kg

Settings
# exclusive inclusive rows x rows loops node
1. 51.958 225,211.774 ↓ 44,280.0 44,280 1

Sort (cost=64,035.98..64,035.99 rows=1 width=46) (actual time=225,206.235..225,211.774 rows=44,280 loops=1)

  • Sort Key: aml.date_maturity, aml.id
  • Sort Method: quicksort Memory: 7,398kB
2.          

CTE jnl_precision

3. 0.160 1.788 ↑ 1.0 24 1

Hash Right Join (cost=4.43..10.18 rows=24 width=8) (actual time=1.766..1.788 rows=24 loops=1)

  • Hash Cond: (currency.id = COALESCE(j.currency_id, c.currency_id))
4. 1.408 1.408 ↑ 1.0 170 1

Seq Scan on res_currency currency (cost=0.00..4.70 rows=170 width=8) (actual time=0.084..1.408 rows=170 loops=1)

5. 0.028 0.220 ↑ 1.0 24 1

Hash (cost=4.13..4.13 rows=24 width=12) (actual time=0.219..0.220 rows=24 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
6. 0.070 0.192 ↑ 1.0 24 1

Hash Left Join (cost=1.14..4.13 rows=24 width=12) (actual time=0.064..0.192 rows=24 loops=1)

  • Hash Cond: (j.company_id = c.id)
7. 0.101 0.101 ↑ 1.0 24 1

Seq Scan on account_journal j (cost=0.00..2.89 rows=24 width=12) (actual time=0.012..0.101 rows=24 loops=1)

  • Filter: ((type)::text = ANY ('{bank,cash}'::text[]))
  • Rows Removed by Filter: 47
8. 0.006 0.021 ↑ 1.0 6 1

Hash (cost=1.06..1.06 rows=6 width=8) (actual time=0.021..0.021 rows=6 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
9. 0.015 0.015 ↑ 1.0 6 1

Seq Scan on res_company c (cost=0.00..1.06 rows=6 width=8) (actual time=0.012..0.015 rows=6 loops=1)

10.          

CTE partners_table

11. 0.130 0.130 ↑ 1.0 131 1

Values Scan on "*VALUES*" (cost=0.00..1.64 rows=131 width=8) (actual time=0.014..0.130 rows=131 loops=1)

12. 10,297.350 225,159.816 ↓ 44,280.0 44,280 1

Nested Loop Left Join (cost=6.85..64,024.15 rows=1 width=46) (actual time=79.360..225,159.816 rows=44,280 loops=1)

  • Join Filter: (account.id = aml.account_id)
  • Rows Removed by Join Filter: 134,375,194
  • Filter: ((((aml.account_id = journal.default_credit_account_id) OR (aml.account_id = journal.default_debit_account_id)) AND (aml.statement_id IS NULL) AND ((company.account_bank_reconciliation_start IS NULL) OR (aml.date > company.account_bank_reconciliation_start))) OR ((account.reconcile IS TRUE) AND (aml.reconciled IS FALSE)))
  • Rows Removed by Filter: 681,804
13. 713.594 205,423.374 ↓ 726,084.0 726,084 1

Nested Loop Left Join (cost=6.85..63,938.07 rows=1 width=117) (actual time=3.411..205,423.374 rows=726,084 loops=1)

  • Filter: (((line_partner.partner_id <> 0) AND (aml.partner_id = line_partner.partner_id)) OR ((line_partner.partner_id = 0) AND (btrim(regexp_replace((st_line.name)::text, '[^0-9|^\s]'::text, ''::text, 'g'::text)) <> ''::text) AND ((regexp_split_to_array(btrim(regexp_replace((move.name)::text, '[^0-9|^\s]'::text, ''::text, 'g'::text)), '\s+'::text) && regexp_split_to_array(btrim(regexp_replace((st_line.name)::text, '[^0-9|^\s]'::text, ''::text, 'g'::text)), '\s+'::text)) OR ((move.ref IS NOT NULL) AND (regexp_split_to_array(btrim(regexp_replace((move.ref)::text, '[^0-9|^\s]'::text, ''::text, 'g'::text)), '\s+'::text) && regexp_split_to_array(btrim(regexp_replace((st_line.name)::text, '[^0-9|^\s]'::text, ''::text, 'g'::text)), '\s+'::text))))))
14. 373.910 202,531.528 ↓ 11,170.5 726,084 1

Hash Left Join (cost=6.42..63,903.45 rows=65 width=92) (actual time=2.932..202,531.528 rows=726,084 loops=1)

  • Hash Cond: (st_line.company_id = company.id)
  • Filter: (COALESCE(st_line.currency_id, journal.currency_id, company.currency_id) = COALESCE(aml.currency_id, company.currency_id))
15. 44,874.937 202,157.562 ↓ 55.5 726,084 1

Nested Loop (cost=5.29..63,838.27 rows=13,083 width=100) (actual time=2.812..202,157.562 rows=726,084 loops=1)

  • Join Filter: ((line_partner.partner_id = 0) OR (aml.partner_id = line_partner.partner_id))
  • Rows Removed by Join Filter: 244,058,745
16. 0.368 6.779 ↓ 126.0 126 1

Nested Loop Left Join (cost=4.86..368.87 rows=1 width=58) (actual time=2.567..6.779 rows=126 loops=1)

  • Join Filter: (jnl_precision.journal_id = journal.id)
  • Rows Removed by Join Filter: 2,898
17. 0.706 4.143 ↓ 126.0 126 1

Nested Loop Left Join (cost=4.86..368.09 rows=1 width=62) (actual time=0.750..4.143 rows=126 loops=1)

  • Join Filter: (journal.id = st_line.journal_id)
  • Rows Removed by Join Filter: 2,268
18. 0.434 2.933 ↓ 126.0 126 1

Hash Join (cost=4.86..364.49 rows=1 width=50) (actual time=0.702..2.933 rows=126 loops=1)

  • Hash Cond: (st_line.id = line_partner.line_id)
19. 2.185 2.185 ↑ 1.0 131 1

Index Scan using account_bank_statement_line_pkey on account_bank_statement_line st_line (cost=0.29..359.42 rows=131 width=46) (actual time=0.323..2.185 rows=131 loops=1)

  • Index Cond: (id = ANY ('{23295,23294,23424,23423,23422,23421,23420,23419,23418,23417,23416,23415,23414,23413,23412,23411,23410,23409,23408,23407,23406,23405,23404,23403,23402,23401,23400,23399,23398,23397,23396,23395,23394,23393,23392,23391,23390,23389,23388,23387,23386,23385,23384,23383,23382,23381,23380,23379,23378,23377,23376,23375,23374,23373,23372,23371,23370,23369,23368,23367,23366,23365,23364,23363,23362,23361,23360,23359,23358,23357,23356,23355,23354,23353,23352,23351,23350,23349,23348,23347,23346,23345,23344,23343,23342,23341,23340,23339,23338,23337,23336,23335,23334,23333,23332,23331,23330,23329,23328,23327,23326,23325,23324,23323,23322,23321,23320,23319,23318,23317,23316,23315,23314,23313,23312,23311,23310,23309,23308,23307,23306,23305,23304,23303,23302,23301,23300,23299,23298,23297,23296}'::integer[]))
20. 0.049 0.314 ↑ 1.0 126 1

Hash (cost=2.95..2.95 rows=130 width=8) (actual time=0.314..0.314 rows=126 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 13kB
21. 0.265 0.265 ↑ 1.0 126 1

CTE Scan on partners_table line_partner (cost=0.00..2.95 rows=130 width=8) (actual time=0.031..0.265 rows=126 loops=1)

  • Filter: (partner_id <> 0)
  • Rows Removed by Filter: 5
22. 0.504 0.504 ↑ 3.7 19 126

Seq Scan on account_journal journal (cost=0.00..2.71 rows=71 width=16) (actual time=0.003..0.004 rows=19 loops=126)

23. 2.268 2.268 ↑ 1.0 24 126

CTE Scan on jnl_precision (cost=0.00..0.48 rows=24 width=4) (actual time=0.014..0.018 rows=24 loops=126)

24. 157,275.846 157,275.846 ↓ 2.1 1,942,737 126

Index Scan using account_move_line_company_id_index on account_move_line aml (cost=0.43..49,619.68 rows=923,315 width=52) (actual time=0.024..1,248.221 rows=1,942,737 loops=126)

  • Index Cond: (company_id = st_line.company_id)
  • Filter: CASE WHEN (st_line.amount > 0.0) THEN (balance > '0'::numeric) ELSE (balance < '0'::numeric) END
  • Rows Removed by Filter: 1,466,239
25. 0.012 0.056 ↑ 1.0 6 1

Hash (cost=1.06..1.06 rows=6 width=12) (actual time=0.056..0.056 rows=6 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
26. 0.044 0.044 ↑ 1.0 6 1

Seq Scan on res_company company (cost=0.00..1.06 rows=6 width=12) (actual time=0.024..0.044 rows=6 loops=1)

27. 2,178.252 2,178.252 ↑ 1.0 1 726,084

Index Scan using account_move_pkey on account_move move (cost=0.43..0.47 rows=1 width=41) (actual time=0.003..0.003 rows=1 loops=726,084)

  • Index Cond: (id = aml.move_id)
28. 9,439.092 9,439.092 ↑ 9.3 186 726,084

Seq Scan on account_account account (cost=0.00..51.35 rows=1,735 width=11) (actual time=0.001..0.013 rows=186 loops=726,084)