explain.depesz.com

PostgreSQL's explain analyze made readable

Result: gbhC

Settings
# exclusive inclusive rows x rows loops node
1. 0.040 330.239 ↑ 1.0 50 1

Limit (cost=3.25..1,822.30 rows=50 width=352) (actual time=9.309..330.239 rows=50 loops=1)

2. 5.277 330.199 ↑ 50.4 50 1

Nested Loop Anti Join (cost=3.25..91,610.62 rows=2,518 width=352) (actual time=9.307..330.199 rows=50 loops=1)

  • Join Filter: (((z.exp_tipo)::text = (b.exp_tipo)::text) AND (z.emp_codigo = a.emp_codigo) AND (z.access_id = a.access_id) AND ((z.exp_modo)::text = (b.exp_modo)::text))
3. 3.418 256.336 ↑ 1.8 1,491 1

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

4. 16.583 179.712 ↑ 2.3 1,494 1

Nested Loop (cost=2.26..57,761.99 rows=3,375 width=414) (actual time=0.402..179.712 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.887 85.144 ↑ 2.9 1,733 1

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

6. 1.433 4.272 ↑ 4.1 1,733 1

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

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

8. 0.004 0.213 ↑ 8.0 1 1

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

9. 0.033 0.199 ↑ 8.0 1 1

Nested Loop (cost=0.00..158.00 rows=8 width=292) (actual time=0.199..0.199 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.045 0.150 ↓ 2.9 29 6

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

12. 0.105 0.105 ↓ 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.105 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.010 0.010 ↑ 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.010..0.010 rows=1 loops=1)

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

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

  • Index Cond: ((emp_codigo = e.emp_codigo) AND (mod = '55'::text))
  • Heap Fetches: 93
16. 77.985 77.985 ↑ 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.044..0.045 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. 77.985 77.985 ↑ 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.045..0.045 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. 73.206 73.206 ↑ 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.048..0.049 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. 68.586 68.586 ↑ 1.0 1 1,491

Index Scan using idx_app_varitus_export_nfe_nfce on app_varitus_export_nfe_nfce z (cost=0.42..5.33 rows=1 width=60) (actual time=0.046..0.046 rows=1 loops=1,491)

  • Index Cond: (((cnpj_emitente)::text = (ne.cnpj_emitente)::text) AND ((mod)::text = (ne.mod)::text) AND ((mod)::text = '55'::text) AND (numero = ne.numero) AND (serie = ne.serie) AND (tpamb = ne.tpamb))
  • Filter: (((exp_tipo)::text = 'VARITUS_EXPORT_NFE'::text) AND ((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 : 191.963 ms