explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ILLk

Settings
# exclusive inclusive rows x rows loops node
1. 0.006 80.918 ↑ 10.0 1 1

HashAggregate (cost=3,380.02..3,380.14 rows=10 width=82) (actual time=80.918..80.918 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.541 80.912 ↑ 10.0 1 1

GroupAggregate (cost=3,379.42..3,379.82 rows=10 width=82) (actual time=80.912..80.912 rows=1 loops=1)

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

Sort (cost=3,379.42..3,379.44 rows=10 width=82) (actual time=80.365..80.371 rows=148 loops=1)

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

Nested Loop (cost=79.99..3,379.25 rows=10 width=82) (actual time=57.749..79.860 rows=148 loops=1)

5. 0.434 78.803 ↓ 14.8 148 1

Nested Loop Left Join (cost=3.42..2,573.15 rows=10 width=65) (actual time=57.734..78.803 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. 2.875 77.629 ↓ 14.8 148 1

Nested Loop Left Join (cost=3.13..2,568.21 rows=10 width=69) (actual time=57.722..77.629 rows=148 loops=1)

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

Nested Loop (cost=2.71..236.22 rows=21 width=67) (actual time=34.177..61.202 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. 6.824 33.607 ↓ 50.4 9,987 1

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

9. 3.417 6.809 ↓ 50.4 9,987 1

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

10. 0.001 0.052 ↑ 1.0 1 1

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

11. 0.002 0.044 ↑ 1.0 1 1

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

12. 0.003 0.040 ↑ 1.0 1 1

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

13. 0.002 0.021 ↑ 1.0 1 1

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

14. 0.013 0.013 ↑ 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.013 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.016 0.016 ↑ 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.016 rows=1 loops=1)

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

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

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

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

  • Index Cond: (codigo = historico.matriculaperiodo)
19. 3.340 3.340 ↓ 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.015..3.340 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.316 9.680 ↑ 7.7 3 1,936

Append (cost=0.00..205.12 rows=23 width=4) (actual time=0.000..0.005 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. 0.000 5.364 ↓ 0.0 0 1,788

Nested Loop Semi Join (cost=4.73..204.86 rows=20 width=4) (actual time=0.003..0.003 rows=0 loops=1,788)

29. 1.788 5.364 ↓ 0.0 0 1,788

Nested Loop (cost=4.73..204.41 rows=20 width=8) (actual time=0.003..0.003 rows=0 loops=1,788)

30. 1.788 3.576 ↓ 0.0 0 1,788

Bitmap Heap Scan on turmaagrupada ta (cost=4.44..50.06 rows=20 width=8) (actual time=0.002..0.002 rows=0 loops=1,788)

  • Recheck Cond: (turma = horarioturma.turma)
31. 1.788 1.788 ↓ 0.0 0 1,788

Bitmap Index Scan on idx_turmaagrupada_turma (cost=0.00..4.44 rows=20 width=0) (actual time=0.001..0.001 rows=0 loops=1,788)

  • 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.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 : 29.124 ms
Execution time : 81.220 ms