explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 7gUV

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

Limit (cost=2.81..752.66 rows=50 width=352) (actual time=135.042..1,320.143 rows=50 loops=1)

2. 0.460 1,320.120 ↑ 611.1 50 1

Merge Join (cost=2.81..458,247.99 rows=30,556 width=352) (actual time=135.041..1,320.120 rows=50 loops=1)

  • Merge Cond: ((a.emp_codigo = b.emp_codigo) AND (a.access_id = b.access_id))
3. 0.065 0.065 ↑ 11.7 19 1

Index Scan using pk_conexao on app_acesso_externo a (cost=0.15..418.53 rows=223 width=218) (actual time=0.029..0.065 rows=19 loops=1)

  • Filter: ((access_tipo)::text = ANY ('{DATABASE,FOLDER}'::text[]))
4. 0.104 1,319.595 ↑ 460.5 50 1

Materialize (cost=2.67..456,330.59 rows=23,024 width=150) (actual time=134.947..1,319.595 rows=50 loops=1)

5. 10.602 1,319.491 ↑ 460.5 50 1

Nested Loop Anti Join (cost=2.67..456,273.03 rows=23,024 width=150) (actual time=134.938..1,319.491 rows=50 loops=1)

6. 16.581 1,029.589 ↑ 2.2 11,172 1

Nested Loop (cost=2.24..395,427.47 rows=24,400 width=179) (actual time=0.232..1,029.589 rows=11,172 loops=1)

7. 95.374 666.459 ↑ 2.8 11,179 1

Nested Loop (cost=1.68..251,936.60 rows=31,146 width=179) (actual time=0.179..666.459 rows=11,179 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: 6,145
8. 19.994 34.010 ↑ 3.1 17,325 1

Nested Loop (cost=1.12..7,329.79 rows=53,101 width=109) (actual time=0.092..34.010 rows=17,325 loops=1)

  • Join Filter: ((b.emp_codigo = ne.emp_codigo) AND (((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))))
  • Rows Removed by Join Filter: 25
9. 0.023 0.087 ↑ 3.3 3 1

Nested Loop (cost=0.56..159.39 rows=10 width=96) (actual time=0.058..0.087 rows=3 loops=1)

10. 0.028 0.028 ↑ 3.3 3 1

Index Scan using pk_exportacao on app_exportacao_aut b (cost=0.27..75.44 rows=10 width=78) (actual time=0.021..0.028 rows=3 loops=1)

  • Index Cond: ((exp_tipo)::text = 'VARITUS_EXPORT_NFE'::text)
  • Filter: (((exp_tipo_doc)::text = 'TODOS'::text) OR ((exp_tipo_doc)::text = 'EMITIDAS'::text) OR ((exp_tipo_doc)::text = 'RECEBIDAS'::text))
11. 0.036 0.036 ↑ 1.0 1 3

Index Scan using empresa_pkey on empresa e (cost=0.29..8.35 rows=1 width=18) (actual time=0.011..0.012 rows=1 loops=3)

  • Index Cond: (emp_codigo = b.emp_codigo)
12. 13.929 13.929 ↓ 1.2 5,783 3

Index Only Scan using pk_nfe_empresa on nfe_empresa ne (cost=0.56..415.18 rows=4,644 width=33) (actual time=0.015..4.643 rows=5,783 loops=3)

  • Index Cond: ((emp_codigo = e.emp_codigo) AND (mod = '55'::text))
  • Heap Fetches: 203
13. 537.075 537.075 ↑ 1.0 1 17,325

Index Scan using pk_nfe_ident on nfe_ident ni (cost=0.56..4.55 rows=1 width=82) (actual time=0.030..0.031 rows=1 loops=17,325)

  • Index Cond: (((cnpj_emitente)::text = (ne.cnpj_emitente)::text) AND (numero = ne.numero) AND (serie = ne.serie) AND (tpamb = ne.tpamb) AND ((mod)::text = '55'::text))
14. 346.549 346.549 ↑ 1.0 1 11,179

Index Scan using pk_nfe on nfe n (cost=0.56..4.56 rows=1 width=29) (actual time=0.030..0.031 rows=1 loops=11,179)

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

Index Only Scan using idx_app_varitus_export_nfe_nfce on app_varitus_export_nfe_nfce z (cost=0.42..2.49 rows=1 width=33) (actual time=0.025..0.025 rows=1 loops=11,172)

  • Index Cond: ((cnpj_emitente = (ne.cnpj_emitente)::text) AND (mod = (ne.mod)::text) AND (mod = '55'::text) AND (numero = ne.numero) AND (serie = ne.serie) AND (tpamb = ne.tpamb) AND (emp_codigo = ne.emp_codigo))
  • Heap Fetches: 48
Planning time : 59.203 ms