explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 8A4j

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

HashAggregate (cost=2,929.56..2,929.68 rows=10 width=82) (actual time=102.607..102.607 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.540 102.601 ↑ 10.0 1 1

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

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

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

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

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

5. 0.457 100.461 ↓ 14.8 148 1

Nested Loop Left Join (cost=3.42..2,122.69 rows=10 width=65) (actual time=75.773..100.461 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.016 99.264 ↓ 14.8 148 1

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

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

Nested Loop (cost=2.71..236.22 rows=21 width=67) (actual time=34.235..62.400 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. 7.347 34.236 ↓ 50.4 9,987 1

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

9. 3.422 6.915 ↓ 50.4 9,987 1

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

10. 0.001 0.053 ↑ 1.0 1 1

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

11. 0.003 0.045 ↑ 1.0 1 1

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

12. 0.002 0.040 ↑ 1.0 1 1

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

13. 0.004 0.023 ↑ 1.0 1 1

Nested Loop (cost=0.71..16.76 rows=1 width=60) (actual time=0.022..0.023 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.015 0.015 ↑ 1.0 1 1

Index Scan using matricula_pkey on matricula (cost=0.29..8.31 rows=1 width=13) (actual time=0.015..0.015 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.440 3.440 ↓ 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.440 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. 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)
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.001..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. 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)

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

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 : 30.070 ms
Execution time : 102.916 ms