explain.depesz.com

PostgreSQL's explain analyze made readable

Result: LOO

Settings
# exclusive inclusive rows x rows loops node
1. 0.008 102.790 ↑ 10.0 1 1

HashAggregate (cost=2,929.56..2,929.68 rows=10 width=82) (actual time=102.790..102.790 rows=1 loops=1)

  • Group Key: max(pessoa.codigo), array_to_string(array_agg(DISTINCT pessoa.nome), ', '::text), array_agg(DISTINCT pessoa.codigo), disciplina.codigo, disciplina.nome, min(horarioturmadiaitem.data), max(horarioturmadiaitem.data), 'PRESENCIAL'::text
2. 0.543 102.782 ↑ 10.0 1 1

GroupAggregate (cost=2,928.96..2,929.36 rows=10 width=82) (actual time=102.782..102.782 rows=1 loops=1)

  • Group Key: disciplina.codigo, disciplina.nome, matriculaperiodoturmadisciplina.modalidadedisciplina
3. 0.527 102.239 ↓ 14.8 148 1

Sort (cost=2,928.96..2,928.98 rows=10 width=82) (actual time=102.225..102.239 rows=148 loops=1)

  • Sort Key: disciplina.codigo, disciplina.nome, matriculaperiodoturmadisciplina.modalidadedisciplina
  • Sort Method: quicksort Memory: 45kB
4. 0.198 101.712 ↓ 14.8 148 1

Nested Loop (cost=79.99..2,928.79 rows=10 width=82) (actual time=76.010..101.712 rows=148 loops=1)

5. 0.439 100.626 ↓ 14.8 148 1

Nested Loop Left Join (cost=3.42..2,122.69 rows=10 width=65) (actual time=75.989..100.626 rows=148 loops=1)

  • Join Filter: ((((curso.periodicidade)::text = 'AN'::text) AND ((professortitulardisciplinaturma.ano)::text = (matriculaperiodo.ano)::text)) OR (((curso.periodicidade)::text = 'SE'::text) AND ((professortitulardisciplinaturma.ano)::text = (matriculaperiodo.ano)::text) AND ((professortitulardisciplinaturma.semestre)::text = (matriculaperiodo.semestre)::text)) OR ((curso.periodicidade)::text = 'IN'::text))
  • Rows Removed by Join Filter: 444
6. 3.605 99.447 ↓ 14.8 148 1

Nested Loop Left Join (cost=3.13..2,117.75 rows=10 width=69) (actual time=75.969..99.447 rows=148 loops=1)

  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 1788
7. 8.075 62.930 ↓ 92.2 1,936 1

Nested Loop (cost=2.71..236.22 rows=21 width=67) (actual time=34.773..62.930 rows=1,936 loops=1)

  • Join Filter: ((((curso.periodicidade)::text = 'AN'::text) AND ((horarioturma.anovigente)::text = (matriculaperiodo.ano)::text)) OR (((curso.periodicidade)::text = 'SE'::text) AND ((horarioturma.anovigente)::text = (matriculaperiodo.ano)::text) AND ((horarioturma.semestrevigente)::text = (matriculaperiodo.semestre)::text)) OR ((curso.periodicidade)::text = 'IN'::text))
  • Rows Removed by Join Filter: 8051
8. 8.065 34.881 ↓ 50.4 9,987 1

Nested Loop (cost=2.42..170.07 rows=198 width=67) (actual time=0.078..34.881 rows=9,987 loops=1)

9. 3.484 6.842 ↓ 50.4 9,987 1

Nested Loop (cost=1.99..75.03 rows=198 width=67) (actual time=0.070..6.842 rows=9,987 loops=1)

10. 0.002 0.062 ↑ 1.0 1 1

Nested Loop (cost=1.57..33.71 rows=1 width=59) (actual time=0.053..0.062 rows=1 loops=1)

11. 0.002 0.051 ↑ 1.0 1 1

Nested Loop (cost=1.15..25.25 rows=1 width=54) (actual time=0.044..0.051 rows=1 loops=1)

12. 0.002 0.044 ↑ 1.0 1 1

Nested Loop (cost=1.00..25.08 rows=1 width=55) (actual time=0.039..0.044 rows=1 loops=1)

13. 0.003 0.025 ↑ 1.0 1 1

Nested Loop (cost=0.71..16.76 rows=1 width=60) (actual time=0.022..0.025 rows=1 loops=1)

14. 0.016 0.016 ↑ 1.0 1 1

Index Scan using historico_pkey on historico (cost=0.43..8.45 rows=1 width=21) (actual time=0.014..0.016 rows=1 loops=1)

  • Index Cond: (codigo = 2007739)
15. 0.006 0.006 ↑ 1.0 1 1

Index Scan using disciplina_pkey on disciplina (cost=0.28..8.30 rows=1 width=39) (actual time=0.005..0.006 rows=1 loops=1)

  • Index Cond: (codigo = historico.disciplina)
16. 0.017 0.017 ↑ 1.0 1 1

Index Scan using matricula_pkey on matricula (cost=0.29..8.31 rows=1 width=13) (actual time=0.016..0.017 rows=1 loops=1)

  • Index Cond: ((matricula)::text = (historico.matricula)::text)
17. 0.005 0.005 ↑ 1.0 1 1

Index Scan using curso_pkey on curso (cost=0.14..0.17 rows=1 width=7) (actual time=0.004..0.005 rows=1 loops=1)

  • Index Cond: (codigo = matricula.curso)
18. 0.009 0.009 ↑ 1.0 1 1

Index Scan using matriculaperiodo_pkey on matriculaperiodo (cost=0.42..8.44 rows=1 width=13) (actual time=0.007..0.009 rows=1 loops=1)

  • Index Cond: (codigo = historico.matriculaperiodo)
19. 3.296 3.296 ↓ 12.7 9,987 1

Index Scan using idx_horturdiaitem_disciplina on horarioturmadiaitem (cost=0.43..33.47 rows=786 width=16) (actual time=0.016..3.296 rows=9,987 loops=1)

  • Index Cond: (disciplina = disciplina.codigo)
20. 19.974 19.974 ↑ 1.0 1 9,987

Index Scan using horarioturmadia_pkey on horarioturmadia (cost=0.42..0.47 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=9,987)

  • Index Cond: (codigo = horarioturmadiaitem.horarioturmadia)
21. 19.974 19.974 ↑ 1.0 1 9,987

Index Scan using horarioturma_pkey on horarioturma (cost=0.29..0.31 rows=1 width=13) (actual time=0.001..0.002 rows=1 loops=9,987)

  • Index Cond: (codigo = horarioturmadia.horarioturma)
22. 3.872 3.872 ↑ 1.0 1 1,936

Index Scan using matriculaperiodoturmadisciplina_pkey on matriculaperiodoturmadisciplina (cost=0.43..8.45 rows=1 width=26) (actual time=0.002..0.002 rows=1 loops=1,936)

  • Index Cond: (codigo = historico.matriculaperiodoturmadisciplina)
23.          

SubPlan (forNested Loop Left Join)

24. 4.008 29.040 ↑ 20.7 3 1,936

Append (cost=0.00..162.12 rows=62 width=4) (actual time=0.000..0.015 rows=3 loops=1,936)

25. 0.000 0.000 ↑ 1.0 1 1,936

Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=1 loops=1,936)

26. 0.000 0.000 ↑ 1.0 1 1,936

Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=1 loops=1,936)

27. 0.000 0.000 ↑ 1.0 1 1,936

Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=1 loops=1,936)

28. 1.788 25.032 ↓ 0.0 0 1,788

Nested Loop (cost=4.79..161.47 rows=59 width=4) (actual time=0.014..0.014 rows=0 loops=1,788)

29. 5.364 23.244 ↓ 0.0 0 1,788

Nested Loop (cost=4.51..133.99 rows=59 width=4) (actual time=0.013..0.013 rows=0 loops=1,788)

30. 3.576 7.152 ↑ 1.0 3 1,788

HashAggregate (cost=0.07..0.10 rows=3 width=4) (actual time=0.003..0.004 rows=3 loops=1,788)

  • Group Key: (CASE WHEN ((matriculaperiodoturmadisciplina.turmateorica IS NULL) AND (matriculaperiodoturmadisciplina.turmapratica IS NULL) AND (matriculaperiodoturmadisciplina.turma IS NOT NULL)) THEN matriculaperiodoturmadisciplina.turma ELSE CASE WHEN (matriculaperiodo.turma IS NOT NULL) THEN matriculaperiodo.turma ELSE 0 END END)
31. 3.576 3.576 ↑ 1.0 3 1,788

Append (cost=0.00..0.06 rows=3 width=4) (actual time=0.000..0.002 rows=3 loops=1,788)

32. 0.000 0.000 ↑ 1.0 1 1,788

Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=1 loops=1,788)

33. 0.000 0.000 ↑ 1.0 1 1,788

Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=1 loops=1,788)

34. 0.000 0.000 ↑ 1.0 1 1,788

Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=1 loops=1,788)

35. 0.000 10.728 ↓ 0.0 0 5,364

Bitmap Heap Scan on turmaagrupada ta (cost=4.44..44.43 rows=20 width=8) (actual time=0.002..0.002 rows=0 loops=5,364)

  • Recheck Cond: (turma = (CASE WHEN ((matriculaperiodoturmadisciplina.turmateorica IS NULL) AND (matriculaperiodoturmadisciplina.turmapratica IS NULL) AND (matriculaperiodoturmadisciplina.turma IS NOT NULL)) THEN matriculaperiodoturmadisciplina.turma ELSE CASE WHEN (matriculaperiodo.turma IS NOT NULL) THEN matriculaperiodo.turma ELSE 0 END END))
36. 10.728 10.728 ↓ 0.0 0 5,364

Bitmap Index Scan on idx_turmaagrupada_turma (cost=0.00..4.44 rows=20 width=0) (actual time=0.002..0.002 rows=0 loops=5,364)

  • Index Cond: (turma = (CASE WHEN ((matriculaperiodoturmadisciplina.turmateorica IS NULL) AND (matriculaperiodoturmadisciplina.turmapratica IS NULL) AND (matriculaperiodoturmadisciplina.turma IS NOT NULL)) THEN matriculaperiodoturmadisciplina.turma ELSE CASE WHEN (matriculaperiodo.turma IS NOT NULL) THEN matriculaperiodo.turma ELSE 0 END END))
37. 0.000 0.000 ↓ 0.0 0

Index Only Scan using turma_pkey on turma t (cost=0.29..0.46 rows=1 width=4) (never executed)

  • Index Cond: (codigo = ta.turmaorigem)
  • Heap Fetches: 0
38. 0.740 0.740 ↓ 4.0 4 148

Index Scan using idx_professortitulardisciplinaturma_tur_dis_ano_sem on professortitulardisciplinaturma (cost=0.29..0.47 rows=1 width=21) (actual time=0.002..0.005 rows=4 loops=148)

  • Index Cond: ((turma = horarioturma.turma) AND (disciplina = disciplina.codigo))
  • Filter: titular
39. 0.296 0.888 ↑ 1.0 1 148

Bitmap Heap Scan on pessoa (cost=76.57..80.60 rows=1 width=29) (actual time=0.006..0.006 rows=1 loops=148)

  • Recheck Cond: (((professortitulardisciplinaturma.professor = codigo) AND (codigo IS NOT NULL)) OR ((codigo = horarioturmadiaitem.professor) AND (codigo IS NOT NULL)))
  • Filter: (((professortitulardisciplinaturma.codigo IS NOT NULL) AND (professortitulardisciplinaturma.professor = codigo)) OR ((professortitulardisciplinaturma.codigo IS NULL) AND (codigo = horarioturmadiaitem.professor)))
  • Heap Blocks: exact=148
40. 0.148 0.592 ↓ 0.0 0 148

BitmapOr (cost=76.57..76.57 rows=2 width=0) (actual time=0.004..0.004 rows=0 loops=148)

41. 0.296 0.296 ↑ 1.0 1 148

Bitmap Index Scan on pessoa_pkey (cost=0.00..0.50 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=148)

  • Index Cond: ((professortitulardisciplinaturma.professor = codigo) AND (codigo IS NOT NULL))
42. 0.148 0.148 ↑ 1.0 1 148

Bitmap Index Scan on pessoa_pkey (cost=0.00..0.43 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=148)

  • Index Cond: ((codigo = horarioturmadiaitem.professor) AND (codigo IS NOT NULL))
Planning time : 32.656 ms
Execution time : 103.118 ms