explain.depesz.com

PostgreSQL's explain analyze made readable

Result: PDxK

Settings
# exclusive inclusive rows x rows loops node
1. 0.023 289.517 ↑ 1.0 50 1

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

2. 3.227 289.494 ↑ 50.4 50 1

Nested Loop Anti Join (cost=3.37..100,411.53 rows=2,518 width=352) (actual time=15.650..289.494 rows=50 loops=1)

3. 2.826 181.897 ↑ 1.8 1,491 1

Nested Loop (cost=2.82..77,033.81 rows=2,698 width=356) (actual time=0.568..181.897 rows=1,491 loops=1)

4. 11.686 128.275 ↑ 2.3 1,494 1

Nested Loop (cost=2.26..57,761.99 rows=3,375 width=414) (actual time=0.503..128.275 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. 2.546 61.133 ↑ 2.9 1,733 1

Nested Loop (cost=1.70..29,121.84 rows=5,015 width=344) (actual time=0.422..61.133 rows=1,733 loops=1)

6. 1.224 3.131 ↑ 4.1 1,733 1

Nested Loop (cost=1.13..6,081.67 rows=7,127 width=315) (actual time=0.326..3.131 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.011 0.272 ↑ 8.0 1 1

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

8. 0.004 0.242 ↑ 8.0 1 1

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

9. 0.042 0.225 ↑ 8.0 1 1

Nested Loop (cost=0.00..158.00 rows=8 width=292) (actual time=0.225..0.225 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.021 0.021 ↑ 37.2 6 1

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

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

Materialize (cost=0.00..14.63 rows=10 width=78) (actual time=0.004..0.027 rows=29 loops=6)

12. 0.110 0.110 ↓ 3.2 32 1

Seq Scan on app_exportacao_aut b (cost=0.00..14.58 rows=10 width=78) (actual time=0.011..0.110 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.013 0.013 ↑ 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.013..0.013 rows=1 loops=1)

  • Index Cond: (emp_codigo = a.emp_codigo)
14. 0.019 0.019 ↑ 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.019..0.019 rows=1 loops=1)

  • Index Cond: ((emp_cnpj)::text = (e_1.emp_cnpj)::text)
15. 1.635 1.635 ↑ 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.043..1.635 rows=1,733 loops=1)

  • Index Cond: ((emp_codigo = e.emp_codigo) AND (mod = '55'::text))
  • Heap Fetches: 93
16. 55.456 55.456 ↑ 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.032..0.032 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. 55.456 55.456 ↑ 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.032..0.032 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. 50.796 50.796 ↑ 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.034..0.034 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. 104.370 104.370 ↑ 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.070..0.070 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 : 201.486 ms