explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 70b7

Settings
# exclusive inclusive rows x rows loops node
1. 0.010 180.786 ↑ 21.0 1 1

HashAggregate (cost=3,870.32..3,870.59 rows=21 width=82) (actual time=180.786..180.786 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. 9.117 180.776 ↑ 21.0 1 1

GroupAggregate (cost=3,869.06..3,869.90 rows=21 width=82) (actual time=180.776..180.776 rows=1 loops=1)

  • Group Key: disciplina.codigo, disciplina.nome, matriculaperiodoturmadisciplina.modalidadedisciplina
3. 6.860 171.659 ↓ 92.2 1,936 1

Sort (cost=3,869.06..3,869.12 rows=21 width=82) (actual time=171.572..171.659 rows=1,936 loops=1)

  • Sort Key: disciplina.codigo, disciplina.nome, matriculaperiodoturmadisciplina.modalidadedisciplina
  • Sort Method: quicksort Memory: 321kB
4. 2.152 164.799 ↓ 92.2 1,936 1

Nested Loop (cost=80.28..3,868.60 rows=21 width=82) (actual time=68.790..164.799 rows=1,936 loops=1)

5. 6.741 149.095 ↓ 92.2 1,936 1

Nested Loop Left Join (cost=3.71..2,175.79 rows=21 width=65) (actual time=68.760..149.095 rows=1,936 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: 7152
6. 0.960 128.802 ↓ 92.2 1,936 1

Nested Loop Left Join (cost=3.42..2,165.41 rows=21 width=69) (actual time=68.732..128.802 rows=1,936 loops=1)

7. 15.132 122.034 ↓ 92.2 1,936 1

Nested Loop (cost=2.99..1,987.85 rows=21 width=63) (actual time=68.721..122.034 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. 5.287 86.928 ↓ 50.4 9,987 1

Nested Loop (cost=2.57..311.29 rows=198 width=67) (actual time=0.083..86.928 rows=9,987 loops=1)

9. 4.647 61.667 ↓ 50.4 9,987 1

Nested Loop (cost=2.28..224.80 rows=198 width=67) (actual time=0.076..61.667 rows=9,987 loops=1)

10. 9.686 37.046 ↓ 50.4 9,987 1

Nested Loop (cost=2.00..161.61 rows=198 width=62) (actual time=0.070..37.046 rows=9,987 loops=1)

11. 3.595 7.386 ↓ 50.4 9,987 1

Nested Loop (cost=1.57..66.58 rows=198 width=62) (actual time=0.061..7.386 rows=9,987 loops=1)

12. 0.002 0.050 ↑ 1.0 1 1

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

13. 0.001 0.043 ↑ 1.0 1 1

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

14. 0.004 0.024 ↑ 1.0 1 1

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

15. 0.015 0.015 ↑ 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.015 rows=1 loops=1)

  • Index Cond: (codigo = 2007739)
16. 0.005 0.005 ↑ 1.0 1 1

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

  • Index Cond: (codigo = historico.disciplina)
17. 0.018 0.018 ↑ 1.0 1 1

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

  • Index Cond: ((matricula)::text = (historico.matricula)::text)
18. 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)
19. 3.741 3.741 ↓ 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.017..3.741 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.002..0.002 rows=1 loops=9,987)

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

Index Only Scan using turma_pkey on turma (cost=0.29..0.43 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=9,987)

  • Index Cond: (codigo = horarioturma.turma)
  • Heap Fetches: 9987
23. 19.974 19.974 ↑ 1.0 1 9,987

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

  • Index Cond: (codigo = historico.matriculaperiodo)
24. 5.808 5.808 ↑ 1.0 1 1,936

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

  • Index Cond: (codigo = historico.matriculaperiodoturmadisciplina)
25. 13.552 13.552 ↓ 5.0 5 1,936

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.007 rows=5 loops=1,936)

  • Index Cond: ((turma = turma.codigo) AND (disciplina = disciplina.codigo))
  • Filter: titular
  • Rows Removed by Filter: 3
26. 5.808 13.552 ↑ 1.0 1 1,936

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

  • 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)))
  • Rows Removed by Filter: 0
  • Heap Blocks: exact=2424
27. 0.000 7.744 ↓ 0.0 0 1,936

BitmapOr (cost=76.57..76.57 rows=2 width=0) (actual time=0.004..0.004 rows=0 loops=1,936)

28. 3.872 3.872 ↑ 1.0 1 1,936

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

  • Index Cond: ((professortitulardisciplinaturma.professor = codigo) AND (codigo IS NOT NULL))
29. 3.872 3.872 ↑ 1.0 1 1,936

Bitmap Index Scan on pessoa_pkey (cost=0.00..0.43 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=1,936)

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