explain.depesz.com

PostgreSQL's explain analyze made readable

Result: cFAf

Settings
# exclusive inclusive rows x rows loops node
1. 19.908 1,284.099 ↓ 307.0 307 1

Nested Loop (cost=2.12..23.73 rows=1 width=203) (actual time=103.827..1,284.099 rows=307 loops=1)

  • Join Filter: (((ni.cnpj_emitente)::text = (ng.cnpj_emitente)::text) AND ((ni.mod)::text = (ng.mod)::text) AND (ni.numero = ng.numero) AND (ni.serie = ng.serie) AND (ni.tpamb = ng.tpamb))
2. 40.156 1,125.129 ↓ 12,642.0 12,642 1

Nested Loop (cost=1.56..20.41 rows=1 width=261) (actual time=0.298..1,125.129 rows=12,642 loops=1)

  • Join Filter: (((ni.cnpj_emitente)::text = (ne.cnpj_emitente)::text) AND ((ni.mod)::text = (ne.mod)::text) AND (ni.numero = ne.numero) AND (ni.serie = ne.serie) AND (ni.tpamb = ne.tpamb))
3. 39.181 579.293 ↓ 12,642.0 12,642 1

Nested Loop (cost=1.00..17.19 rows=1 width=232) (actual time=0.184..579.293 rows=12,642 loops=1)

4. 21.790 21.790 ↓ 12,642.0 12,642 1

Index Scan using idx_nfe_ident_dhemi on nfe_ident ni (cost=0.44..8.50 rows=1 width=29) (actual time=0.071..21.790 rows=12,642 loops=1)

  • Index Cond: ((dhemi >= '2020-08-17 00:00:00-03'::timestamp with time zone) AND (dhemi <= '2020-08-26 00:00:00-03'::timestamp with time zone))
5. 518.322 518.322 ↑ 1.0 1 12,642

Index Scan using pk_nfe on nfe n (cost=0.56..8.64 rows=1 width=203) (actual time=0.041..0.041 rows=1 loops=12,642)

  • Index Cond: (((cnpj_emitente)::text = (ni.cnpj_emitente)::text) AND (numero = ni.numero) AND (serie = ni.serie) AND (tpamb = ni.tpamb) AND ((mod)::text = (ni.mod)::text))
6. 505.680 505.680 ↑ 1.0 1 12,642

Index Only Scan using pk_nfe_emitente on nfe_emitente ne (cost=0.56..3.16 rows=1 width=29) (actual time=0.040..0.040 rows=1 loops=12,642)

  • Index Cond: ((cnpj_emitente = (n.cnpj_emitente)::text) AND (numero = n.numero) AND (serie = n.serie) AND (tpamb = n.tpamb) AND (mod = (n.mod)::text))
  • Heap Fetches: 12,639
7. 139.062 139.062 ↓ 0.0 0 12,642

Index Only Scan using pk_nfe_empresa on nfe_empresa ng (cost=0.56..3.26 rows=1 width=29) (actual time=0.011..0.011 rows=0 loops=12,642)

  • Index Cond: ((emp_codigo = 11,149) AND (cnpj_emitente = (ne.cnpj_emitente)::text) AND (numero = ne.numero) AND (serie = ne.serie) AND (tpamb = ne.tpamb) AND (mod = (ne.mod)::text))
  • Heap Fetches: 307