explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 6BnD

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

HashAggregate (cost=4,681.19..4,681.31 rows=10 width=82) (actual time=162.014..162.014 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.547 162.006 ↑ 10.0 1 1

GroupAggregate (cost=4,680.59..4,680.99 rows=10 width=82) (actual time=162.006..162.006 rows=1 loops=1)

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

Sort (cost=4,680.59..4,680.61 rows=10 width=82) (actual time=161.454..161.459 rows=148 loops=1)

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

Nested Loop (cost=80.28..4,680.42 rows=10 width=82) (actual time=119.160..160.925 rows=148 loops=1)

5. 0.458 159.837 ↓ 14.8 148 1

Nested Loop Left Join (cost=3.71..3,874.32 rows=10 width=65) (actual time=119.138..159.837 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.630 158.639 ↓ 14.8 148 1

Nested Loop Left Join (cost=3.42..3,869.37 rows=10 width=69) (actual time=119.116..158.639 rows=148 loops=1)

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

Nested Loop (cost=2.99..1,987.85 rows=21 width=71) (actual time=67.782..121.161 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.223 86.406 ↓ 50.4 9,987 1

Nested Loop (cost=2.57..311.29 rows=198 width=71) (actual time=0.085..86.406 rows=9,987 loops=1)

9. 4.784 61.209 ↓ 50.4 9,987 1

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

10. 9.163 36.451 ↓ 50.4 9,987 1

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

11. 3.616 7.314 ↓ 50.4 9,987 1

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

12. 0.001 0.054 ↑ 1.0 1 1

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

13. 0.002 0.047 ↑ 1.0 1 1

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

14. 0.005 0.024 ↑ 1.0 1 1

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

15. 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.012..0.013 rows=1 loops=1)

  • Index Cond: (codigo = 2007739)
16. 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)
17. 0.021 0.021 ↑ 1.0 1 1

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

  • Index Cond: ((matricula)::text = (historico.matricula)::text)
18. 0.006 0.006 ↑ 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.006 rows=1 loops=1)

  • Index Cond: (codigo = matricula.curso)
19. 3.644 3.644 ↓ 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.644 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=13) (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=26) (actual time=0.002..0.003 rows=1 loops=1,936)

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

SubPlan (forNested Loop Left Join)

26. 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)

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

29. 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)

30. 0.000 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)

31. 7.152 25.032 ↓ 0.0 0 1,788

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

32. 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)
33. 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)

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

36. 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)

37. 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))
38. 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))
39. 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
40. 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 = turma.codigo) AND (disciplina = disciplina.codigo))
  • Filter: titular
41. 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
42. 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)

43. 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))
44. 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 : 26.984 ms
Execution time : 162.357 ms