explain.depesz.com

PostgreSQL's explain analyze made readable

Result: BTaL

Settings
# exclusive inclusive rows x rows loops node
1. 0.007 19.898 ↑ 1.0 1 1

HashAggregate (cost=329.46..329.47 rows=1 width=82) (actual time=19.897..19.898 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.512 19.891 ↑ 1.0 1 1

GroupAggregate (cost=329.40..329.44 rows=1 width=82) (actual time=19.891..19.891 rows=1 loops=1)

  • Group Key: disciplina.codigo, disciplina.nome, matriculaperiodoturmadisciplina.modalidadedisciplina
3. 0.532 19.379 ↓ 148.0 148 1

Sort (cost=329.40..329.40 rows=1 width=82) (actual time=19.376..19.379 rows=148 loops=1)

  • Sort Key: disciplina.codigo, disciplina.nome, matriculaperiodoturmadisciplina.modalidadedisciplina
  • Sort Method: quicksort Memory: 45kB
4. 0.230 18.847 ↓ 148.0 148 1

Nested Loop (cost=83.92..329.39 rows=1 width=82) (actual time=0.120..18.847 rows=148 loops=1)

5. 0.508 17.729 ↓ 148.0 148 1

Nested Loop Left Join (cost=3.42..240.98 rows=1 width=65) (actual time=0.103..17.729 rows=148 loops=1)

  • Join Filter: ((professortitulardisciplinaturma.turma = horarioturma.turma) AND ((((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: 592
6. 1.113 16.333 ↓ 148.0 148 1

Nested Loop (cost=3.13..240.48 rows=1 width=69) (actual time=0.092..16.333 rows=148 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)) AND (SubPlan 1))
  • Rows Removed by Join Filter: 588
7. 0.809 13.452 ↓ 736.0 736 1

Nested Loop (cost=2.71..129.42 rows=1 width=85) (actual time=0.077..13.452 rows=736 loops=1)

8. 0.590 11.907 ↓ 736.0 736 1

Nested Loop (cost=2.56..129.24 rows=1 width=86) (actual time=0.074..11.907 rows=736 loops=1)

9. 0.812 5.429 ↓ 736.0 736 1

Nested Loop Left Join (cost=2.27..120.92 rows=1 width=91) (actual time=0.057..5.429 rows=736 loops=1)

10. 0.300 3.145 ↓ 736.0 736 1

Nested Loop (cost=1.85..112.47 rows=1 width=73) (actual time=0.048..3.145 rows=736 loops=1)

11. 0.389 1.373 ↓ 736.0 736 1

Nested Loop (cost=1.56..112.16 rows=1 width=42) (actual time=0.043..1.373 rows=736 loops=1)

  • Join Filter: (historico.disciplina = horarioturmadiaitem.disciplina)
12. 0.072 0.248 ↓ 3.4 184 1

Nested Loop (cost=1.14..61.01 rows=54 width=34) (actual time=0.033..0.248 rows=184 loops=1)

13. 0.003 0.031 ↓ 2.5 5 1

Nested Loop (cost=0.71..19.99 rows=2 width=34) (actual time=0.022..0.031 rows=5 loops=1)

14. 0.014 0.014 ↑ 1.0 1 1

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

  • Index Cond: (codigo = 1873744)
15. 0.014 0.014 ↓ 2.5 5 1

Index Scan using ch_horarioturma_turma_ano_semestre on horarioturma (cost=0.29..11.52 rows=2 width=13) (actual time=0.007..0.014 rows=5 loops=1)

  • Index Cond: (turma = 16563)
16. 0.145 0.145 ↓ 1.2 37 5

Index Scan using fk_horarioturmadia_horarioturma on horarioturmadia (cost=0.42..20.20 rows=31 width=8) (actual time=0.007..0.029 rows=37 loops=5)

  • Index Cond: (horarioturma = horarioturma.codigo)
17. 0.736 0.736 ↑ 2.0 4 184

Index Scan using idx_horturdiaitem_horturmdia on horarioturmadiaitem (cost=0.43..0.85 rows=8 width=16) (actual time=0.003..0.004 rows=4 loops=184)

  • Index Cond: (horarioturmadia = horarioturmadia.codigo)
18. 1.472 1.472 ↑ 1.0 1 736

Index Scan using disciplina_pkey on disciplina (cost=0.28..0.30 rows=1 width=39) (actual time=0.002..0.002 rows=1 loops=736)

  • Index Cond: (codigo = horarioturmadiaitem.disciplina)
19. 1.472 1.472 ↑ 1.0 1 736

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=736)

  • Index Cond: (codigo = historico.matriculaperiodoturmadisciplina)
20. 5.888 5.888 ↑ 1.0 1 736

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

  • Index Cond: ((matricula)::text = (historico.matricula)::text)
21. 0.736 0.736 ↑ 1.0 1 736

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

  • Index Cond: (codigo = matricula.curso)
22. 1.472 1.472 ↑ 1.0 1 736

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

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

SubPlan (forNested Loop)

24. 0.296 0.296 ↑ 7.7 3 148

Append (cost=0.00..205.12 rows=23 width=4) (actual time=0.000..0.002 rows=3 loops=148)

25. 0.000 0.000 ↑ 1.0 1 148

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

26. 0.000 0.000 ↑ 1.0 1 148

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

27. 0.000 0.000 ↑ 1.0 1 148

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

28. 0.000 0.000 ↓ 0.0 0

Nested Loop Semi Join (cost=4.73..204.86 rows=20 width=4) (never executed)

29. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=4.73..204.41 rows=20 width=8) (never executed)

30. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on turmaagrupada ta (cost=4.44..50.06 rows=20 width=8) (never executed)

  • Recheck Cond: (turma = horarioturma.turma)
31. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on idx_turmaagrupada_turma (cost=0.00..4.44 rows=20 width=0) (never executed)

  • Index Cond: (turma = horarioturma.turma)
32. 0.000 0.000 ↓ 0.0 0

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

  • Index Cond: (codigo = ta.turmaorigem)
  • Heap Fetches: 0
33. 0.000 0.000 ↓ 0.0 0

Materialize (cost=0.00..0.08 rows=3 width=4) (never executed)

34. 0.000 0.000 ↓ 0.0 0

Append (cost=0.00..0.07 rows=3 width=4) (never executed)

35. 0.000 0.000 ↓ 0.0 0

Result (cost=0.00..0.01 rows=1 width=0) (never executed)

  • One-Time Filter: (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 = horarioturma.turma)
36. 0.000 0.000 ↓ 0.0 0

Result (cost=0.00..0.01 rows=1 width=0) (never executed)

  • One-Time Filter: (CASE WHEN (matriculaperiodoturmadisciplina.turmapratica IS NOT NULL) THEN matriculaperiodoturmadisciplina.turmapratica ELSE 0 END = horarioturma.turma)
37. 0.000 0.000 ↓ 0.0 0

Result (cost=0.00..0.01 rows=1 width=0) (never executed)

  • One-Time Filter: (CASE WHEN (matriculaperiodoturmadisciplina.turmateorica IS NOT NULL) THEN matriculaperiodoturmadisciplina.turmateorica ELSE 0 END = horarioturma.turma)
38. 0.888 0.888 ↓ 5.0 5 148

Index Scan using idx_professortitulardisciplinaturma_tur_dis_ano_sem on professortitulardisciplinaturma (cost=0.29..0.47 rows=1 width=21) (actual time=0.003..0.006 rows=5 loops=148)

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

Bitmap Heap Scan on pessoa (cost=80.50..88.40 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=80.50..80.50 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..4.43 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 : 21.526 ms
Execution time : 20.195 ms