explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Zvaq

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 51.753 18,232.558 ↓ 4.6 36,180 1

Sort (cost=863,879.72..863,899.43 rows=7,883 width=1,033) (actual time=18,231.105..18,232.558 rows=36,180 loops=1)

  • Sort Key: (CASE WHEN (a_7.num_doc = ''::bpchar) THEN 0 ELSE (a_7.num_doc)::integer END)
  • Sort Method: quicksort Memory: 20192kB
2. 67.993 18,180.805 ↓ 4.6 36,180 1

Hash Left Join (cost=762,317.73..863,369.51 rows=7,883 width=1,033) (actual time=16,443.959..18,180.805 rows=36,180 loops=1)

  • Hash Cond: (a_7.cod_sit = b_2.cod_sit)
3. 33.221 18,112.793 ↓ 7.3 36,180 1

Hash Left Join (cost=762,300.53..862,926.13 rows=4,927 width=1,174) (actual time=16,443.925..18,112.793 rows=36,180 loops=1)

  • Hash Cond: (a_7.ind_pgto = b_1.cod_tipo)
4. 39.466 18,079.558 ↓ 7.3 36,180 1

Hash Left Join (cost=762,299.44..862,905.57 rows=4,927 width=1,144) (actual time=16,443.901..18,079.558 rows=36,180 loops=1)

  • Hash Cond: (a_7.cod_mod = b_3.modelo)
5. 31.507 18,040.062 ↓ 7.3 36,180 1

Hash Left Join (cost=762,296.61..862,875.15 rows=4,927 width=1,115) (actual time=16,443.861..18,040.062 rows=36,180 loops=1)

  • Hash Cond: (a_7.ind_emit = b_4.cod_ind)
6. 30.255 18,008.542 ↓ 7.3 36,180 1

Hash Left Join (cost=762,295.52..862,854.60 rows=4,927 width=1,085) (actual time=16,443.841..18,008.542 rows=36,180 loops=1)

  • Hash Cond: (a_7.ind_oper = b_5.cod_ind)
7. 19.557 17,978.272 ↓ 7.3 36,180 1

Hash Left Join (cost=762,294.47..862,834.59 rows=4,927 width=1,055) (actual time=16,443.819..17,978.272 rows=36,180 loops=1)

  • Hash Cond: (a_7.ind_frt = b.cod_tipo_frt)
8. 500.500 17,958.686 ↓ 7.3 36,180 1

Hash Join (cost=762,293.38..862,764.76 rows=4,927 width=851) (actual time=16,443.776..17,958.686 rows=36,180 loops=1)

  • Hash Cond: (a_7.fk_0000 = b_6.id)
9. 971.968 17,458.105 ↑ 1.0 985,443 1

Unique (cost=762,287.29..848,513.55 rows=985,443 width=787) (actual time=15,488.753..17,458.105 rows=985,443 loops=1)

10. 11,924.868 16,486.137 ↓ 1.0 985,447 1

Sort (cost=762,287.29..764,750.90 rows=985,443 width=787) (actual time=15,488.751..16,486.137 rows=985,447 loops=1)

  • Sort Key: ((a_7.id)::text), a_7.fk_0000, a_7.ind_oper, a_7.ind_emit, (CASE WHEN ((b_7.cod_part IS NOT NULL) AND (b_7.nome IS NOT NULL)) THEN (((b_7.cod_part)::text || ' - '::text) || (b_7.nome)::text) ELSE CASE WHEN ((b_7.cod_part IS NULL) OR (b_7.nome IS NULL)) THEN ''::text ELSE ''::text END END), a_7.cod_mod, a_7.cod_sit, a_7.ser, a_7.num_doc, a_7.chv_nfe, (CASE WHEN ((a_7.dt_doc = ''::bpchar) OR (a_7.dt_doc IS NULL)) THEN ''::text ELSE ((((""substring""((a_7.dt_doc)::text, 1, 2) || '/'::text) || ""substring""((a_7.dt_doc)::text, 3, 2)) || '/'::text) || ""substring""((a_7.dt_doc)::text, 5, 4)) END), (((((""substring""((a_7.dt_e_s)::text, 1, 2) || '/'::text) || ""substring""((a_7.dt_e_s)::text, 3, 2)) || '/'::text) || ""substring""((a_7.dt_e_s)::text, 5, 4))), ((a_7.vl_doc)::text), a_7.ind_pgto, ((a_7.vl_desc)::text), ((a_7.vl_abat_nt)::text), ((a_7.vl_merc)::text), a_7.ind_frt, ((a_7.vl_frt)::text), ((a_7.vl_seg)::text), ((a_7.vl_out_da)::text), ((a_7.vl_bc_icms)::text), ((a_7.vl_icms)::text), ((a_7.vl_bc_icms_st)::text), ((a_7.vl_icms_st)::text), ((a_7.vl_ipi)::text), ((a_7.vl_pis)::text), ((a_7.vl_confins)::text), ((a_7.vl_pis_st)::text), ((a_7.vl_confins_st)::text), a_7.situacao_conferencia, (CASE WHEN (b_7.cnpj IS NULL) THEN ''::bpchar ELSE CASE WHEN (b_7.cnpj = ''::bpchar) THEN b_7.cpf ELSE b_7.cnpj END END), (CASE WHEN (b_7.ie IS NULL) THEN ''::bpchar ELSE b_7.ie END), (CASE WHEN ((a_7.xml IS NULL) OR (a_7.xml = ''::text)) THEN false ELSE true END)
  • Sort Method: external merge Disk: 203304kB
11. 3,503.669 4,561.269 ↓ 1.0 985,447 1

Hash Left Join (cost=705.95..320,624.41 rows=985,443 width=787) (actual time=6.761..4,561.269 rows=985,447 loops=1)

  • Hash Cond: ((a_7.fk_0000 = b_7.fk_0000) AND (a_7.cod_part = b_7.cod_part))
12. 1,050.926 1,050.926 ↑ 1.0 985,443 1

Seq Scan on reg_c100 a_7 (cost=0.00..48,244.43 rows=985,443 width=230) (actual time=0.017..1,050.926 rows=985,443 loops=1)

  • Filter: ((ind_oper IS NOT NULL) AND (ind_emit IS NOT NULL) AND (cod_mod IS NOT NULL) AND (cod_sit IS NOT NULL) AND (ind_pgto IS NOT NULL) AND (ind_frt IS NOT NULL))
13. 3.467 6.674 ↑ 1.0 8,278 1

Hash (cost=581.78..581.78 rows=8,278 width=208) (actual time=6.674..6.674 rows=8,278 loops=1)

  • Buckets: 16384 Batches: 1 Memory Usage: 2069kB
14. 3.207 3.207 ↑ 1.0 8,278 1

Seq Scan on reg_0150 b_7 (cost=0.00..581.78 rows=8,278 width=208) (actual time=0.012..3.207 rows=8,278 loops=1)

15. 0.004 0.081 ↑ 1.0 1 1

Hash (cost=6.08..6.08 rows=1 width=13) (actual time=0.081..0.081 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
16. 0.077 0.077 ↑ 1.0 1 1

Seq Scan on reg_0000 b_6 (cost=0.00..6.08 rows=1 width=13) (actual time=0.076..0.077 rows=1 loops=1)

  • Filter: (((""substring""((dt_in)::text, 5, 4) || ""substring""((dt_in)::text, 3, 2)) >= '201904'::text) AND ((""substring""((dt_in)::text, 5, 4) || ""substring""((dt_in)::text, 3, 2)) <= '201904'::text))
  • Rows Removed by Filter: 51
17. 0.004 0.029 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=209) (actual time=0.029..0.029 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
18. 0.025 0.025 ↑ 1.0 4 1

Seq Scan on indicador_tipo_frete b (cost=0.00..1.04 rows=4 width=209) (actual time=0.024..0.025 rows=4 loops=1)

19. 0.003 0.015 ↑ 1.0 2 1

Hash (cost=1.02..1.02 rows=2 width=109) (actual time=0.015..0.015 rows=2 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
20. 0.012 0.012 ↑ 1.0 2 1

Seq Scan on indicador_tipo_oper b_5 (cost=0.00..1.02 rows=2 width=109) (actual time=0.012..0.012 rows=2 loops=1)

21. 0.002 0.013 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=109) (actual time=0.013..0.013 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
22. 0.011 0.011 ↑ 1.0 4 1

Seq Scan on indicador_emitente b_4 (cost=0.00..1.04 rows=4 width=109) (actual time=0.011..0.011 rows=4 loops=1)

23. 0.012 0.030 ↑ 1.0 37 1

Hash (cost=2.37..2.37 rows=37 width=210) (actual time=0.030..0.030 rows=37 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 17kB
24. 0.018 0.018 ↑ 1.0 37 1

Seq Scan on modelo_doc_fiscal b_3 (cost=0.00..2.37 rows=37 width=210) (actual time=0.010..0.018 rows=37 loops=1)

25. 0.003 0.014 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=109) (actual time=0.014..0.014 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
26. 0.011 0.011 ↑ 1.0 4 1

Seq Scan on indicador_tipo_pgto b_1 (cost=0.00..1.04 rows=4 width=109) (actual time=0.010..0.011 rows=4 loops=1)

27. 0.006 0.019 ↑ 22.9 14 1

Hash (cost=13.20..13.20 rows=320 width=210) (actual time=0.019..0.019 rows=14 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 12kB
28. 0.013 0.013 ↑ 22.9 14 1

Seq Scan on sit_doc_fiscal b_2 (cost=0.00..13.20 rows=320 width=210) (actual time=0.010..0.013 rows=14 loops=1)

Planning time : 4.747 ms