explain.depesz.com

PostgreSQL's explain analyze made readable

Result: MS5e

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.002 4,901.788 ↓ 0.0 0 1

Limit (cost=396,059.84..396,068.88 rows=3,617 width=124) (actual time=4,901.788..4,901.788 rows=0 loops=1)

2. 0.050 4,901.786 ↓ 0.0 0 1

Sort (cost=396,059.84..396,068.88 rows=3,617 width=124) (actual time=4,901.786..4,901.786 rows=0 loops=1)

  • Sort Key: estdocite.cd_empresa, estdocite.cd_filial_utiliz, estdoc.dt_movimento, opeest.id_entrada_saida
  • Sort Method: quicksort Memory: 25kB
3. 0.001 4,901.736 ↓ 0.0 0 1

Append (cost=1.16..395,809.89 rows=3,617 width=46) (actual time=4,901.736..4,901.736 rows=0 loops=1)

4. 0.001 4,901.689 ↓ 0.0 0 1

Result (cost=1.16..395,792.41 rows=3,616 width=46) (actual time=4,901.689..4,901.689 rows=0 loops=1)

5. 0.002 4,901.688 ↓ 0.0 0 1

Append (cost=1.16..395,792.41 rows=3,616 width=46) (actual time=4,901.688..4,901.688 rows=0 loops=1)

6. 0.000 0.477 ↓ 0.0 0 1

Nested Loop (cost=1.16..27.56 rows=1 width=46) (actual time=0.477..0.477 rows=0 loops=1)

  • Join Filter: (estdocite.cd_filial_utiliz = pesfil.cd_filial)
7. 0.001 0.477 ↓ 0.0 0 1

Nested Loop (cost=1.01..26.42 rows=1 width=54) (actual time=0.477..0.477 rows=0 loops=1)

  • Join Filter: ((estdoc.dt_movimento < to_date('2019-05-10'::text, 'yyyy-MM-dd'::text)) OR ((estdoc.dt_movimento = to_date('2019-05-10'::text, 'yyyy-MM-dd'::text)) AND ((estdoc.hr_movimento)::text <= '020040'::text) AND (opeest.id_entrada_saida = 'E'::bpchar)) OR (opeest.id_entrada_saida = 'S'::bpchar))
8. 0.011 0.476 ↓ 0.0 0 1

Nested Loop (cost=0.87..18.23 rows=1 width=66) (actual time=0.476..0.476 rows=0 loops=1)

9. 0.201 0.201 ↓ 22.0 22 1

Index Scan using est_doc_item_idx2 on est_doc_item estdocite (cost=0.43..9.76 rows=1 width=48) (actual time=0.071..0.201 rows=22 loops=1)

  • Index Cond: (id_atualizado = ANY ('{Q,N}'::bpchar[]))
10. 0.264 0.264 ↓ 0.0 0 22

Index Scan using est_documento_pk on est_documento estdoc (cost=0.43..8.46 rows=1 width=34) (actual time=0.012..0.012 rows=0 loops=22)

  • Index Cond: ((cd_empresa = estdocite.cd_empresa) AND (cd_base = estdocite.cd_base) AND (seq_processo = estdocite.seq_processo))
  • Filter: ((id_situacao_eletronica = ANY ('{0,9}'::bpchar[])) AND ((id_situacao_sped)::text = ANY ('{00,01,06,07}'::text[])))
  • Rows Removed by Filter: 1
11. 0.000 0.000 ↓ 0.0 0

Index Scan using operacao_estoque_pk on operacao_estoque opeest (cost=0.15..8.17 rows=1 width=10) (never executed)

  • Index Cond: (cd_operacao = estdocite.cd_operacao)
12. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pessoa_filial_pk on pessoa_filial pesfil (cost=0.14..0.72 rows=33 width=16) (never executed)

  • Index Cond: (cd_empresa = estdoc.cd_empresa)
  • Heap Fetches: 0
13. 0.015 4,901.209 ↓ 0.0 0 1

Hash Join (cost=231,271.46..395,728.70 rows=3,615 width=46) (actual time=4,901.209..4,901.209 rows=0 loops=1)

  • Hash Cond: ((estdoc_1.cd_empresa = pesfil_1.cd_empresa) AND (estdocite_1.cd_filial_utiliz = pesfil_1.cd_filial))
14. 0.010 4,901.099 ↓ 0.0 0 1

Hash Join (cost=231,264.81..395,651.94 rows=3,396 width=54) (actual time=4,901.099..4,901.099 rows=0 loops=1)

  • Hash Cond: (estdocite_1.cd_operacao = opeest_1.cd_operacao)
15. 57.567 4,900.803 ↓ 0.0 0 1

Hash Join (cost=231,248.40..395,588.83 rows=3,396 width=60) (actual time=4,900.803..4,900.803 rows=0 loops=1)

  • Hash Cond: ((estdocite_1.cd_empresa = estdoc_1.cd_empresa) AND (estdocite_1.cd_base = estdoc_1.cd_base) AND (estdocite_1.seq_processo = estdoc_1.seq_processo))
16. 265.180 265.180 ↑ 1.0 244,719 1

Index Scan using est_doc_item_idx2 on est_doc_item estdocite_1 (cost=0.43..161,550.84 rows=244,983 width=48) (actual time=0.091..265.180 rows=244,719 loops=1)

  • Index Cond: (id_atualizado = ANY ('{Q,N,F,S}'::bpchar[]))
  • Filter: (id_atualizado_canc IS NULL)
17. 50.004 4,578.056 ↓ 1.1 68,574 1

Hash (cost=230,203.53..230,203.53 rows=59,682 width=28) (actual time=4,578.056..4,578.056 rows=68,574 loops=1)

  • Buckets: 131072 (originally 65536) Batches: 1 (originally 1) Memory Usage: 5310kB
18. 4,528.052 4,528.052 ↓ 1.1 68,574 1

Seq Scan on est_documento estdoc_1 (cost=0.00..230,203.53 rows=59,682 width=28) (actual time=0.178..4,528.052 rows=68,574 loops=1)

  • Filter: ((id_situacao_eletronica = ANY ('{0,9}'::bpchar[])) AND ((id_situacao_sped)::text = ANY ('{02,03,89}'::text[])))
  • Rows Removed by Filter: 4209099
19. 0.105 0.286 ↓ 1.0 376 1

Hash (cost=11.74..11.74 rows=374 width=10) (actual time=0.286..0.286 rows=376 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 26kB
20. 0.181 0.181 ↓ 1.0 376 1

Seq Scan on operacao_estoque opeest_1 (cost=0.00..11.74 rows=374 width=10) (actual time=0.032..0.181 rows=376 loops=1)

21. 0.021 0.095 ↑ 1.0 66 1

Hash (cost=5.66..5.66 rows=66 width=16) (actual time=0.095..0.095 rows=66 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 12kB
22. 0.074 0.074 ↑ 1.0 66 1

Seq Scan on pessoa_filial pesfil_1 (cost=0.00..5.66 rows=66 width=16) (actual time=0.021..0.074 rows=66 loops=1)

23. 0.001 0.046 ↓ 0.0 0 1

Subquery Scan on *SELECT* 3 (cost=9.96..17.48 rows=1 width=156) (actual time=0.046..0.046 rows=0 loops=1)

24. 0.002 0.045 ↓ 0.0 0 1

Nested Loop (cost=9.96..17.47 rows=1 width=156) (actual time=0.045..0.045 rows=0 loops=1)

25. 0.000 0.043 ↓ 0.0 0 1

Nested Loop (cost=9.81..16.69 rows=1 width=162) (actual time=0.043..0.043 rows=0 loops=1)

  • Join Filter: ((ecfcupfisite.cd_empresa = ecfcupfis.cd_empresa) AND (ecfcupfisite.cd_filial = ecfcupfis.cd_filial) AND ((ecfcupfisite.nr_serie_fab_ecf)::text = (ecfcupfis.nr_serie_fab_ecf)::text) AND (ecfcupfisite.nr_cupom_fiscal = ecfcupfis.nr_cupom_fiscal))
26. 0.024 0.043 ↓ 0.0 0 1

Hash Join (cost=9.67..15.84 rows=1 width=174) (actual time=0.043..0.043 rows=0 loops=1)

  • Hash Cond: ((pesfil_2.cd_empresa = ecfcupfisite.cd_empresa) AND (pesfil_2.cd_filial = ecfcupfisite.cd_filial))
27. 0.009 0.009 ↑ 66.0 1 1

Seq Scan on pessoa_filial pesfil_2 (cost=0.00..5.66 rows=66 width=24) (actual time=0.009..0.009 rows=1 loops=1)

28. 0.001 0.010 ↓ 0.0 0 1

Hash (cost=9.64..9.64 rows=2 width=150) (actual time=0.010..0.010 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
29. 0.002 0.009 ↓ 0.0 0 1

Bitmap Heap Scan on ecf_cupom_fiscal_item ecfcupfisite (cost=4.30..9.64 rows=2 width=150) (actual time=0.009..0.009 rows=0 loops=1)

  • Recheck Cond: (id_atualizado = ANY ('{Q,N}'::bpchar[]))
30. 0.007 0.007 ↓ 0.0 0 1

Bitmap Index Scan on ecf_cupom_fiscal_item_idx1 (cost=0.00..4.30 rows=2 width=0) (actual time=0.007..0.007 rows=0 loops=1)

  • Index Cond: (id_atualizado = ANY ('{Q,N}'::bpchar[]))
31. 0.000 0.000 ↓ 0.0 0

Index Scan using ecf_cupom_fiscal_idx1 on ecf_cupom_fiscal ecfcupfis (cost=0.14..0.83 rows=1 width=146) (never executed)

  • Index Cond: ((cd_empresa = pesfil_2.cd_empresa) AND (cd_filial = pesfil_2.cd_filial))
  • Filter: ((id_situacao_sped)::text = ANY ('{00,01}'::text[]))
32. 0.000 0.000 ↓ 0.0 0

Index Scan using operacao_estoque_pk on operacao_estoque opeest_2 (cost=0.15..0.77 rows=1 width=10) (never executed)

  • Index Cond: (cd_operacao = pesfil_2.cd_operacao_venda)
Planning time : 8.181 ms
Execution time : 4,902.453 ms