explain.depesz.com

PostgreSQL's explain analyze made readable

Result: d9wL

Settings
# exclusive inclusive rows x rows loops node
1. 0.032 434.075 ↑ 1.0 50 1

Limit (cost=3.37..1,997.18 rows=50 width=352) (actual time=26.729..434.075 rows=50 loops=1)

2. 4.885 434.043 ↑ 50.4 50 1

Nested Loop Anti Join (cost=3.37..100,411.47 rows=2,518 width=352) (actual time=26.727..434.043 rows=50 loops=1)

3. 4.315 286.022 ↑ 1.8 1,491 1

Nested Loop (cost=2.82..77,033.75 rows=2,698 width=356) (actual time=1.058..286.022 rows=1,491 loops=1)

4. 21.511 196.549 ↑ 2.3 1,494 1

Nested Loop (cost=2.26..57,761.93 rows=3,375 width=414) (actual time=0.977..196.549 rows=1,494 loops=1)

  • Join Filter: ((b.exp_data_inicio_exportacao IS NULL) OR (to_date(to_char(ni.dhemi, 'YYYY-MM-DD'::text), 'YYYY-MM-DD'::text) >= b.exp_data_inicio_exportacao))
  • Rows Removed by Join Filter: 239
5. 4.305 88.388 ↑ 2.9 1,733 1

Nested Loop (cost=1.70..29,121.78 rows=5,015 width=344) (actual time=0.605..88.388 rows=1,733 loops=1)

6. 2.568 7.831 ↑ 4.1 1,733 1

Nested Loop (cost=1.13..6,081.61 rows=7,127 width=315) (actual time=0.480..7.831 rows=1,733 loops=1)

  • Join Filter: (((b.exp_tipo_doc)::text = 'TODOS'::text) OR (((b.exp_tipo_doc)::text = 'EMITIDAS'::text) AND ((ne.cnpj_emitente)::text = (e.emp_cnpj)::text)) OR (((b.exp_tipo_doc)::text = 'RECEBIDAS'::text) AND ((ne.cnpj_emitente)::text <> (e.emp_cnpj)::text)))
7. 0.009 0.346 ↑ 8.0 1 1

Nested Loop (cost=0.57..253.40 rows=8 width=306) (actual time=0.346..0.346 rows=1 loops=1)

8. 0.004 0.286 ↑ 8.0 1 1

Nested Loop (cost=0.29..211.75 rows=8 width=302) (actual time=0.286..0.286 rows=1 loops=1)

9. 0.044 0.258 ↑ 8.0 1 1

Nested Loop (cost=0.00..157.94 rows=8 width=292) (actual time=0.258..0.258 rows=1 loops=1)

  • Join Filter: ((a.emp_codigo = b.emp_codigo) AND (a.access_id = b.access_id))
  • Rows Removed by Join Filter: 171
10. 0.016 0.016 ↑ 37.2 6 1

Seq Scan on app_acesso_externo a (cost=0.00..15.17 rows=223 width=218) (actual time=0.014..0.016 rows=6 loops=1)

  • Filter: ((access_tipo)::text = ANY ('{DATABASE,FOLDER}'::text[]))
11. 0.041 0.198 ↓ 2.9 29 6

Materialize (cost=0.00..14.57 rows=10 width=78) (actual time=0.003..0.033 rows=29 loops=6)

12. 0.157 0.157 ↓ 3.2 32 1

Seq Scan on app_exportacao_aut b (cost=0.00..14.52 rows=10 width=78) (actual time=0.012..0.157 rows=32 loops=1)

  • Filter: (((exp_tipo)::text = 'VARITUS_EXPORT_NFE'::text) AND (((exp_tipo_doc)::text = 'TODOS'::text) OR ((exp_tipo_doc)::text = 'EMITIDAS'::text) OR ((exp_tipo_doc)::text = 'RECEBIDAS'::text)))
  • Rows Removed by Filter: 196
13. 0.024 0.024 ↑ 1.0 1 1

Index Scan using empresa_pkey on empresa e_1 (cost=0.29..6.68 rows=1 width=18) (actual time=0.024..0.024 rows=1 loops=1)

  • Index Cond: (emp_codigo = a.emp_codigo)
14. 0.051 0.051 ↑ 1.0 1 1

Index Scan using uk_emp_cnpj on empresa e (cost=0.29..5.16 rows=1 width=18) (actual time=0.051..0.051 rows=1 loops=1)

  • Index Cond: ((emp_cnpj)::text = (e_1.emp_cnpj)::text)
15. 4.917 4.917 ↑ 2.7 1,733 1

Index Only Scan using pk_nfe_empresa on nfe_empresa ne (cost=0.56..438.28 rows=4,644 width=33) (actual time=0.121..4.917 rows=1,733 loops=1)

  • Index Cond: ((emp_codigo = e.emp_codigo) AND (mod = '55'::text))
  • Heap Fetches: 93
16. 76.252 76.252 ↑ 1.0 1 1,733

Index Only Scan using pk_nfe_emitente on nfe_emitente nt (cost=0.56..3.18 rows=1 width=29) (actual time=0.043..0.044 rows=1 loops=1,733)

  • Index Cond: ((cnpj_emitente = (ne.cnpj_emitente)::text) AND (numero = ne.numero) AND (serie = ne.serie) AND (tpamb = ne.tpamb) AND (mod = '55'::text))
  • Heap Fetches: 52
17. 86.650 86.650 ↑ 1.0 1 1,733

Index Scan using pk_nfe_ident on nfe_ident ni (cost=0.56..5.65 rows=1 width=82) (actual time=0.050..0.050 rows=1 loops=1,733)

  • Index Cond: (((cnpj_emitente)::text = (nt.cnpj_emitente)::text) AND (numero = nt.numero) AND (serie = nt.serie) AND (tpamb = nt.tpamb) AND ((mod)::text = '55'::text))
18. 85.158 85.158 ↑ 1.0 1 1,494

Index Scan using pk_nfe on nfe n (cost=0.56..5.66 rows=1 width=29) (actual time=0.056..0.057 rows=1 loops=1,494)

  • Index Cond: (((cnpj_emitente)::text = (ni.cnpj_emitente)::text) AND (numero = ni.numero) AND (serie = ni.serie) AND (tpamb = ni.tpamb) AND ((mod)::text = '55'::text))
  • Filter: ((status_varitus)::text = ANY ('{AUTORIZADO,AUTORIZADO_FORA_DO_PRAZO,CANCELADO,DENEGADO}'::text[]))
  • Rows Removed by Filter: 0
19. 143.136 143.136 ↑ 1.0 1 1,491

Index Scan using pk_app_varitus_export_nfe on app_varitus_export_nfe_nfce z (cost=0.55..8.65 rows=1 width=60) (actual time=0.096..0.096 rows=1 loops=1,491)

  • Index Cond: ((emp_codigo = a.emp_codigo) AND (access_id = a.access_id) AND ((exp_tipo)::text = (b.exp_tipo)::text) AND ((exp_tipo)::text = 'VARITUS_EXPORT_NFE'::text) AND ((exp_modo)::text = (b.exp_modo)::text) AND ((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) AND ((mod)::text = '55'::text))
  • Filter: ((data_hora_exp IS NOT NULL) OR (round((date_part('epoch'::text, (now() - data_hora_tent_exp)) / 60::double precision)) < 30::double precision))
Planning time : 264.417 ms