explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ViH9 : Query lenta - 10/05/19

Settings
# exclusive inclusive rows x rows loops node
1. 0.093 12,351.175 ↑ 1.1 33 1

Sort (cost=1,587.94..1,588.03 rows=36 width=161) (actual time=12,351.172..12,351.175 rows=33 loops=1)

  • Sort Key: classejudi0_.ds_classe_judicial
  • Sort Method: quicksort Memory: 33kB
2. 0.079 12,351.082 ↑ 1.1 33 1

Hash Join (cost=1,572.77..1,587.01 rows=36 width=161) (actual time=12,351.011..12,351.082 rows=33 loops=1)

  • Hash Cond: ((classejudi1_.id_classe_judicial)::integer = (classejudi0_.id_classe_judicial)::integer)
3. 35.521 12,350.808 ↑ 10.3 61 1

HashAggregate (cost=1,563.65..1,569.94 rows=629 width=4) (actual time=12,350.784..12,350.808 rows=61 loops=1)

  • Group Key: classejudi1_.id_classe_judicial
4. 32.166 12,315.287 ↓ 4.5 49,387 1

Hash Join (cost=41.24..1,536.11 rows=11,015 width=4) (actual time=1.095..12,315.287 rows=49,387 loops=1)

  • Hash Cond: ((classeapli2_.id_classe_judicial)::integer = (classejudi1_.id_classe_judicial)::integer)
5. 56.833 12,282.816 ↓ 4.5 49,387 1

Hash Join (cost=15.66..1,481.42 rows=11,015 width=4) (actual time=0.773..12,282.816 rows=49,387 loops=1)

  • Hash Cond: ((competenci3_.id_classe_aplicacao)::integer = (classeapli2_.id_classe_aplicacao)::integer)
  • Join Filter: ((SubPlan 1) OR (SubPlan 2))
  • Rows Removed by Join Filter: 82
6. 15.540 56.115 ↓ 2.5 51,863 1

Nested Loop (cost=0.41..754.48 rows=20,894 width=8) (actual time=0.055..56.115 rows=51,863 loops=1)

7. 0.013 0.013 ↑ 1.0 2 1

Seq Scan on tb_competencia competenci4_ (cost=0.00..1.06 rows=2 width=4) (actual time=0.005..0.013 rows=2 loops=1)

  • Filter: ((in_ativo)::bpchar = 'S'::bpchar)
  • Rows Removed by Filter: 3
8. 40.562 40.562 ↓ 2.5 25,932 2

Index Only Scan using tb_competencia_cl_assunto_in06 on tb_competencia_cl_assunto competenci3_ (cost=0.41..272.24 rows=10,447 width=8) (actual time=0.033..20.281 rows=25,932 loops=2)

  • Index Cond: (id_competencia = (competenci4_.id_competencia)::integer)
  • Heap Fetches: 0
9. 0.143 0.330 ↓ 1.0 365 1

Hash (cost=10.72..10.72 rows=362 width=12) (actual time=0.330..0.330 rows=365 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 24kB
10. 0.187 0.187 ↓ 1.0 365 1

Seq Scan on tb_classe_aplicacao classeapli2_ (cost=0.00..10.72 rows=362 width=12) (actual time=0.007..0.187 rows=365 loops=1)

  • Filter: (((in_ativo)::bpchar = 'S'::bpchar) AND ((id_aplicacao_classe)::integer = 1))
  • Rows Removed by Filter: 150
11.          

SubPlan (forHash Join)

12. 99.184 12,169.374 ↑ 22.0 1 49,469

Nested Loop (cost=6.80..23.15 rows=22 width=4) (actual time=0.246..0.246 rows=1 loops=49,469)

13. 297.060 11,922.029 ↑ 22.0 1 49,469

Hash Join (cost=6.80..21.81 rows=22 width=4) (actual time=0.241..0.241 rows=1 loops=49,469)

  • Hash Cond: ((orgaojulga8_.id_orgao_julgador)::integer = (orgaojulga7_.id_orgao_julgador)::integer)
14. 148.161 148.161 ↑ 96.0 1 49,387

Seq Scan on tb_orgao_julgador orgaojulga8_ (cost=0.00..13.11 rows=96 width=4) (actual time=0.003..0.003 rows=1 loops=49,387)

  • Filter: (((in_ativo)::bpchar = 'S'::bpchar) AND ((id_jurisdicao)::integer = 24) AND ((id_aplicacao_classe)::integer = (classeapli2_.id_aplicacao_classe)::integer))
  • Rows Removed by Filter: 1
15. 2,325.043 11,476.808 ↓ 4.0 218 49,469

Hash (cost=6.11..6.11 rows=55 width=8) (actual time=0.232..0.232 rows=218 loops=49,469)

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
16. 8,310.792 9,151.765 ↓ 4.0 218 49,469

Bitmap Heap Scan on tb_org_julg_competencia orgaojulga7_ (cost=2.65..6.11 rows=55 width=8) (actual time=0.028..0.185 rows=218 loops=49,469)

  • Recheck Cond: ((id_competencia)::integer = (competenci4_.id_competencia)::integer)
  • Filter: ((CURRENT_DATE >= (dt_inicio)::timestamp without time zone) AND (((dt_fim)::timestamp without time zone >= CURRENT_DATE) OR (dt_fim IS NULL)))
  • Rows Removed by Filter: 38
  • Heap Blocks: exact=98774
17. 840.973 840.973 ↓ 3.9 256 49,469

Bitmap Index Scan on tb_org_julg_competencia_in02 (cost=0.00..2.63 rows=65 width=0) (actual time=0.017..0.017 rows=256 loops=49,469)

  • Index Cond: ((id_competencia)::integer = (competenci4_.id_competencia)::integer)
18. 98.774 148.161 ↑ 1.0 1 49,387

Materialize (cost=0.00..1.07 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=49,387)

19. 49.387 49.387 ↑ 1.0 1 49,387

Seq Scan on tb_competencia competenci6_ (cost=0.00..1.06 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=49,387)

  • Filter: ((id_competencia)::integer = (competenci4_.id_competencia)::integer)
20. 0.000 0.164 ↓ 0.0 0 82

Nested Loop (cost=0.30..13.45 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=82)

21. 0.082 0.164 ↓ 0.0 0 82

Nested Loop (cost=0.30..12.38 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=82)

22. 0.082 0.082 ↓ 0.0 0 82

Index Scan using tb_orgao_jlgador_colgiado_in05 on tb_orgao_julgador_colgiado orgaojulga11_ (cost=0.14..4.17 rows=1 width=4) (actual time=0.001..0.001 rows=0 loops=82)

  • Index Cond: ((id_jurisdicao)::integer = 24)
  • Filter: (((in_ativo)::bpchar = 'S'::bpchar) AND ((id_aplicacao_classe)::integer = (classeapli2_.id_aplicacao_classe)::integer))
23. 0.000 0.000 ↓ 0.0 0

Index Scan using tb_org_julg_clgiado_compt_in03 on tb_org_julg_clgiado_compet orgaojulga10_ (cost=0.15..4.18 rows=1 width=8) (never executed)

  • Index Cond: (((id_orgao_julgador_colegiado)::integer = (orgaojulga11_.id_orgao_julgador_colegiado)::integer) AND ((id_competencia)::integer = (competenci4_.id_competencia)::integer))
  • Filter: ((CURRENT_DATE >= (dt_inicio)::timestamp without time zone) AND (((dt_fim)::timestamp without time zone >= CURRENT_DATE) OR (dt_fim IS NULL)))
24. 0.000 0.000 ↓ 0.0 0

Seq Scan on tb_competencia competenci9_ (cost=0.00..1.06 rows=1 width=4) (never executed)

  • Filter: ((id_competencia)::integer = (competenci4_.id_competencia)::integer)
25. 0.172 0.305 ↑ 1.0 629 1

Hash (cost=17.71..17.71 rows=629 width=4) (actual time=0.305..0.305 rows=629 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 31kB
26. 0.133 0.133 ↑ 1.0 629 1

Index Only Scan using tb_classe_judicial_pk on tb_classe_judicial classejudi1_ (cost=0.28..17.71 rows=629 width=4) (actual time=0.023..0.133 rows=629 loops=1)

  • Heap Fetches: 0
27. 0.065 0.195 ↑ 1.0 35 1

Hash (cost=8.68..8.68 rows=36 width=161) (actual time=0.195..0.195 rows=35 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 14kB
28. 0.130 0.130 ↑ 1.0 35 1

Index Scan using tb_classe_judicial_in01 on tb_classe_judicial classejudi0_ (cost=0.28..8.68 rows=36 width=161) (actual time=0.020..0.130 rows=35 loops=1)

  • Index Cond: (id_fluxo IS NOT NULL)
  • Filter: (((in_ativo)::bpchar = 'S'::bpchar) AND ((in_inicial)::bpchar = 'S'::bpchar) AND ((in_recursal)::bpchar = 'N'::bpchar))
  • Rows Removed by Filter: 21