explain.depesz.com

PostgreSQL's explain analyze made readable

Result: W69r

Settings
# exclusive inclusive rows x rows loops node
1. 0.005 73,670.030 ↓ 0.0 0 1

Nested Loop (cost=1,561,297.86..1,582,457.09 rows=580 width=204) (actual time=73,670.030..73,670.030 rows=0 loops=1)

2. 0.021 0.075 ↑ 1.0 1 1

Nested Loop (cost=0.57..16.74 rows=1 width=22) (actual time=0.064..0.075 rows=1 loops=1)

3. 0.026 0.026 ↑ 1.0 1 1

Index Scan using empresa_pkey on empresa e (cost=0.29..8.34 rows=1 width=22) (actual time=0.024..0.026 rows=1 loops=1)

  • Index Cond: (emp_codigo = 11,149)
4. 0.028 0.028 ↑ 1.0 1 1

Index Scan using configuracao_pkey on configuracao c (cost=0.29..8.35 rows=1 width=8) (actual time=0.022..0.028 rows=1 loops=1)

  • Index Cond: (conf_codigo = e.conf_codigo)
5. 0.001 73,669.950 ↓ 0.0 0 1

Nested Loop (cost=1,561,297.28..1,582,404.10 rows=580 width=186) (actual time=73,669.950..73,669.950 rows=0 loops=1)

  • Join Filter: (((ng.cnpj_emitente)::text = (n.cnpj_emitente)::text) AND (ng.numero = n.numero) AND (ng.serie = n.serie) AND (ng.tpamb = n.tpamb) AND ((ng.mod)::text = (n.mod)::text))
6. 0.002 73,669.949 ↓ 0.0 0 1

Nested Loop (cost=1,561,296.72..1,577,828.41 rows=806 width=183) (actual time=73,669.949..73,669.949 rows=0 loops=1)

7. 0.012 73,669.947 ↓ 0.0 0 1

Merge Join (cost=1,561,296.16..1,569,368.24 rows=1,361 width=123) (actual time=73,669.947..73,669.947 rows=0 loops=1)

  • Merge Cond: (((ng.cnpj_emitente)::text = (ni.cnpj_emitente)::text) AND (ng.numero = ni.numero) AND (ng.serie = ni.serie) AND (ng.tpamb = ni.tpamb) AND ((ng.mod)::text = (ni.mod)::text))
8. 29,883.058 30,446.167 ↑ 434,910.0 1 1

Sort (cost=198,676.72..199,764.00 rows=434,910 width=41) (actual time=30,446.167..30,446.167 rows=1 loops=1)

  • Sort Key: ng.cnpj_emitente, ng.numero, ng.serie, ng.tpamb, ng.mod
  • Sort Method: external sort Disk: 24,904kB
9. 438.347 563.109 ↓ 1.0 447,966 1

Bitmap Heap Scan on nfe_empresa ng (cost=8,162.99..149,727.17 rows=434,910 width=41) (actual time=166.271..563.109 rows=447,966 loops=1)

  • Recheck Cond: (emp_codigo = 11,149)
  • Heap Blocks: exact=70,307
10. 124.762 124.762 ↓ 1.0 448,591 1

Bitmap Index Scan on idx_nfe_empresa_emp_codigo (cost=0.00..8,054.26 rows=434,910 width=0) (actual time=124.762..124.762 rows=448,591 loops=1)

  • Index Cond: (emp_codigo = 11,149)
11. 0.043 43,223.768 ↓ 0.0 0 1

Sort (cost=1,362,610.99..1,362,860.64 rows=99,862 width=82) (actual time=43,223.768..43,223.768 rows=0 loops=1)

  • Sort Key: ni.cnpj_emitente, ni.numero, ni.serie, ni.tpamb, ni.mod
  • Sort Method: quicksort Memory: 25kB
12. 43,223.725 43,223.725 ↓ 0.0 0 1

Seq Scan on nfe_ident ni (cost=0.00..1,354,318.62 rows=99,862 width=82) (actual time=43,223.725..43,223.725 rows=0 loops=1)

  • Filter: ((to_date(to_char(dhemi, 'YYYY-MM-DD'::text), 'YYYY-MM-DD'::text) >= '2020-08-26'::date) AND (to_date(to_char(dhemi, 'YYYY-MM-DD'::text), 'YYYY-MM-DD'::text) <= '2020-08-26'::date))
  • Rows Removed by Filter: 20,012,499
13. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_nfe_emitente on nfe_emitente ne (cost=0.56..6.17 rows=1 width=60) (never executed)

  • Index Cond: (((cnpj_emitente)::text = (ng.cnpj_emitente)::text) AND (numero = ng.numero) AND (serie = ng.serie) AND (tpamb = ng.tpamb) AND ((mod)::text = (ng.mod)::text))
14. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_nfe on nfe n (cost=0.56..5.61 rows=1 width=76) (never executed)

  • Index Cond: (((cnpj_emitente)::text = (ne.cnpj_emitente)::text) AND (numero = ne.numero) AND (serie = ne.serie) AND (tpamb = ne.tpamb) AND ((mod)::text = (ne.mod)::text))
Planning time : 20.502 ms