explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 8OEe

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 94,427.699 ↑ 1.0 1 1

Aggregate (cost=20,001,062,437.06..20,001,062,437.07 rows=1 width=8) (actual time=94,427.699..94,427.699 rows=1 loops=1)

2. 0.001 94,427.696 ↓ 0.0 0 1

Hash Left Join (cost=20,001,048,417.17..20,001,062,414.29 rows=1,821 width=365) (actual time=94,427.696..94,427.696 rows=0 loops=1)

  • Hash Cond: (a.cod_part = b.cod_part)
3. 2.037 94,427.695 ↓ 0.0 0 1

Hash Join (cost=20,001,047,731.91..20,001,060,758.82 rows=529 width=65) (actual time=94,427.695..94,427.695 rows=0 loops=1)

  • Hash Cond: (a.fk_0000 = a_1.id)
4. 16.438 94,425.549 ↓ 7.1 33,831 1

Merge Anti Join (cost=10,001,047,710.50..10,001,060,714.05 rows=4,763 width=69) (actual time=94,285.177..94,425.549 rows=33,831 loops=1)

  • Merge Cond: ((a_2.fk_c100 = a_3.fk_c100) AND (a_2.cfop = a_3.cfop) AND (a_2.cst_icms = a_3.cst_icms) AND (a_2.aliq_icms = a_3.aliq_icms))
5. 37.812 72,353.977 ↓ 6.8 34,664 1

Sort (cost=569,094.59..569,107.30 rows=5,081 width=113) (actual time=72,349.319..72,353.977 rows=34,664 loops=1)

  • Sort Key: a_2.fk_c100, a_2.cfop, a_2.cst_icms, a_2.aliq_icms
  • Sort Method: quicksort Memory: 10744kB
6. 162.179 72,316.165 ↓ 6.8 34,664 1

Hash Join (cost=564,858.25..568,781.84 rows=5,081 width=113) (actual time=71,746.703..72,316.165 rows=34,664 loops=1)

  • Hash Cond: (a_2.fk_c100 = a.id)
7. 1,639.430 51,907.638 ↓ 4.1 706,751 1

HashAggregate (cost=513,789.30..515,523.48 rows=173,418 width=116) (actual time=51,500.223..51,907.638 rows=706,751 loops=1)

  • Group Key: a_2.id, a_2.reg, a_2.nivel, a_2.cst_icms, a_2.cfop, a_2.aliq_icms, a_2.vl_opr, a_2.vl_bc_icms, a_2.vl_icms, a_2.vl_bc_icms_st, a_2.vl_icms_st, a_2.vl_red_bc, a_2.vl_ipi, a_2.cod_obs, a_2.fk_c100, a_2.fk_0000, a_2.linha, a_2.situacao_conferencia
8. 879.770 50,268.208 ↓ 4.1 706,751 1

Hash Join (cost=431,206.62..505,985.49 rows=173,418 width=116) (actual time=46,205.239..50,268.208 rows=706,751 loops=1)

  • Hash Cond: (a_2.fk_c100 = reg_c170.fk_c100)
9. 3,183.462 3,183.462 ↑ 1.0 2,293,263 1

Seq Scan on reg_c190 a_2 (cost=0.00..68,758.93 rows=2,293,293 width=116) (actual time=0.024..3,183.462 rows=2,293,263 loops=1)

10. 69.141 46,204.976 ↓ 7.0 311,560 1

Hash (cost=430,649.69..430,649.69 rows=44,555 width=4) (actual time=46,204.976..46,204.976 rows=311,560 loops=1)

  • Buckets: 524288 (originally 65536) Batches: 1 (originally 1) Memory Usage: 15050kB
11. 2,465.403 46,135.835 ↓ 7.0 311,560 1

HashAggregate (cost=429,758.59..430,204.14 rows=44,555 width=4) (actual time=46,056.081..46,135.835 rows=311,560 loops=1)

  • Group Key: reg_c170.fk_c100
12. 43,670.432 43,670.432 ↓ 1.0 3,818,398 1

Seq Scan on reg_c170 (cost=0.00..420,212.67 rows=3,818,367 width=4) (actual time=0.012..43,670.432 rows=3,818,398 loops=1)

13. 12.121 20,246.348 ↑ 1.0 27,601 1

Hash (cost=50,708.04..50,708.04 rows=28,873 width=73) (actual time=20,246.348..20,246.348 rows=27,601 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 3087kB
14. 20,234.227 20,234.227 ↑ 1.0 27,601 1

Seq Scan on reg_c100 a (cost=0.00..50,708.04 rows=28,873 width=73) (actual time=951.103..20,234.227 rows=27,601 loops=1)

  • Filter: (ind_emit = '1'::bpchar)
  • Rows Removed by Filter: 957842
15. 100.221 22,055.134 ↑ 4.5 84,338 1

Group (cost=10,000,478,615.90..10,000,483,919.19 rows=381,837 width=17) (actual time=21,935.849..22,055.134 rows=84,338 loops=1)

  • Group Key: a_3.fk_c100, a_3.cfop, a_3.cst_icms, a_3.aliq_icms
16. 341.290 21,954.913 ↑ 1.0 422,033 1

Sort (cost=10,000,478,615.90..10,000,479,676.56 rows=424,263 width=17) (actual time=21,935.840..21,954.913 rows=422,033 loops=1)

  • Sort Key: a_3.fk_c100, a_3.cfop, a_3.cst_icms, a_3.aliq_icms
  • Sort Method: quicksort Memory: 42016kB
17. 1,389.712 21,613.623 ↑ 1.0 422,038 1

Hash Join (cost=10,000,000,021.41..10,000,438,958.77 rows=424,263 width=17) (actual time=205.786..21,613.623 rows=422,038 loops=1)

  • Hash Cond: (a_3.fk_0000 = a_4.id)
18. 20,223.816 20,223.816 ↓ 1.0 3,818,398 1

Seq Scan on reg_c170 a_3 (cost=0.00..420,212.67 rows=3,818,367 width=21) (actual time=0.025..20,223.816 rows=3,818,398 loops=1)

19. 0.003 0.095 ↑ 6.0 1 1

Hash (cost=10,000,000,021.34..10,000,000,021.34 rows=6 width=4) (actual time=0.095..0.095 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
20. 0.064 0.092 ↑ 6.0 1 1

Nested Loop (cost=10,000,000,000.14..10,000,000,021.34 rows=6 width=4) (actual time=0.091..0.092 rows=1 loops=1)

  • Join Filter: (((CASE WHEN (btrim((a_4.dt_in)::text) = ''::text) THEN '000000'::text ELSE (substr((a_4.dt_in)::text, 5, 4) || substr((a_4.dt_in)::text, 3, 2)) END)::integer >= (c_1.data_inicial)::integer) AND ((CASE WHEN (btrim((a_4.dt_in)::text) = ''::text) THEN '000000'::text ELSE (substr((a_4.dt_in)::text, 5, 4) || substr((a_4.dt_in)::text, 3, 2)) END)::integer <= (c_1.data_final)::integer))
  • Rows Removed by Join Filter: 51
21. 0.028 0.028 ↑ 1.0 52 1

Index Scan using reg_0000_pkey on reg_0000 a_4 (cost=0.14..16.28 rows=52 width=13) (actual time=0.013..0.028 rows=52 loops=1)

22. 0.000 0.000 ↑ 1.0 1 52

Materialize (cost=0.00..1.03 rows=1 width=20) (actual time=0.000..0.000 rows=1 loops=52)

23. 0.013 0.013 ↑ 1.0 1 1

Seq Scan on data_correcao c_1 (cost=0.00..1.02 rows=1 width=20) (actual time=0.013..0.013 rows=1 loops=1)

  • Filter: ((tipo_sped)::text = 'FISCAL'::text)
  • Rows Removed by Filter: 1
24. 0.002 0.109 ↑ 6.0 1 1

Hash (cost=10,000,000,021.34..10,000,000,021.34 rows=6 width=4) (actual time=0.109..0.109 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
25. 0.025 0.107 ↑ 6.0 1 1

Nested Loop (cost=10,000,000,000.14..10,000,000,021.34 rows=6 width=4) (actual time=0.106..0.107 rows=1 loops=1)

  • Join Filter: (((CASE WHEN (btrim((a_1.dt_in)::text) = ''::text) THEN '000000'::text ELSE (substr((a_1.dt_in)::text, 5, 4) || substr((a_1.dt_in)::text, 3, 2)) END)::integer >= (c.data_inicial)::integer) AND ((CASE WHEN (btrim((a_1.dt_in)::text) = ''::text) THEN '000000'::text ELSE (substr((a_1.dt_in)::text, 5, 4) || substr((a_1.dt_in)::text, 3, 2)) END)::integer <= (c.data_final)::integer))
  • Rows Removed by Join Filter: 51
26. 0.030 0.030 ↑ 1.0 52 1

Index Scan using reg_0000_pkey on reg_0000 a_1 (cost=0.14..16.28 rows=52 width=13) (actual time=0.014..0.030 rows=52 loops=1)

27. 0.024 0.052 ↑ 1.0 1 52

Materialize (cost=0.00..1.03 rows=1 width=20) (actual time=0.001..0.001 rows=1 loops=52)

28. 0.028 0.028 ↑ 1.0 1 1

Seq Scan on data_correcao c (cost=0.00..1.02 rows=1 width=20) (actual time=0.027..0.028 rows=1 loops=1)

  • Filter: ((tipo_sped)::text = 'FISCAL'::text)
  • Rows Removed by Filter: 1
29. 0.000 0.000 ↓ 0.0 0

Hash (cost=581.78..581.78 rows=8,278 width=61) (never executed)

30. 0.000 0.000 ↓ 0.0 0

Seq Scan on reg_0150 b (cost=0.00..581.78 rows=8,278 width=61) (never executed)

Planning time : 91.412 ms