explain.depesz.com

PostgreSQL's explain analyze made readable

Result: O4nl

Settings
# exclusive inclusive rows x rows loops node
1. 1.218 12,300.373 ↑ 1.1 160 1

Unique (cost=8,686.24..8,697.85 rows=172 width=545) (actual time=12,299.104..12,300.373 rows=160 loops=1)

2. 12.602 12,299.155 ↓ 7.4 1,280 1

Sort (cost=8,686.24..8,686.67 rows=172 width=545) (actual time=12,299.103..12,299.155 rows=1,280 loops=1)

  • Sort Key: turmaavaliacao.identificadorturma, pessoa.nome, matricula.matricula, matricula.situacao, pessoa.codigo, matriculaperiodo.situacaomatriculaperiodo, atividadediscursivarespostaaluno.codigo, turmaavaliacao.codigo, turmaavaliacao.anual, turmaavaliacao.semestral, atividadediscursivarespostaaluno.situacaorespostaatividadediscursiva, matriculaperiodoturmadisciplina.codigo, matriculaperiodoturmadisciplina.matriculaperiodo, atividadediscursiva.codigo, atividadediscursiva.artefatoentrega, atividadediscursiva.enunciado, atividadediscursiva.dataliberacao, atividadediscursiva.datalimiteentrega, calendarioatividadematricula.datainicio, calendarioatividadematricula.datafim, atividadediscursiva.qtddiasaposinicioliberar, atividadediscursiva.qtddiasparaconclusao, atividadediscursiva.definicaodataentregaatividadediscursiva, disciplina.nome, disciplina.codigo, ((SubPlan 1))
  • Sort Method: quicksort Memory: 979kB
3. 2.591 12,286.553 ↓ 7.4 1,280 1

Nested Loop Left Join (cost=8.15..8,679.85 rows=172 width=545) (actual time=1,680.348..12,286.553 rows=1,280 loops=1)

  • Join Filter: ((calendarioatividadematricula.matriculaperiodoturmadisciplina = matriculaperiodoturmadisciplina.codigo) AND ((calendarioatividadematricula.codorigem)::integer = atividadediscursiva.codigo))
  • Rows Removed by Join Filter: 8960
4. 0.376 12,282.682 ↓ 7.4 1,280 1

Nested Loop Left Join (cost=8.15..7,221.07 rows=172 width=521) (actual time=1,680.318..12,282.682 rows=1,280 loops=1)

5. 0.384 12,279.746 ↓ 7.4 1,280 1

Nested Loop Left Join (cost=7.87..6,741.11 rows=172 width=498) (actual time=1,680.307..12,279.746 rows=1,280 loops=1)

6. 4,282.847 12,275.522 ↓ 7.4 1,280 1

Nested Loop (cost=7.58..5,311.79 rows=172 width=477) (actual time=1,680.289..12,275.522 rows=1,280 loops=1)

  • Join Filter: (((NOT turma.turmaagrupada) AND (atividadediscursiva.disciplina = matriculaperiodoturmadisciplina.disciplina)) OR (turma.turmaagrupada AND ((SubPlan 2) OR (atividadediscursiva.disciplina = matriculaperiodoturmadisciplina.disciplina))))
  • Rows Removed by Join Filter: 985849
7. 2.069 2.069 ↓ 1.7 767 1

Seq Scan on atividadediscursiva (cost=0.00..221.34 rows=455 width=390) (actual time=0.017..2.069 rows=767 loops=1)

  • Filter: (((ano)::text = '2020'::text) AND ((semestre)::text = '1'::text))
  • Rows Removed by Filter: 2389
8. 84.633 93.574 ↓ 160.9 1,287 767

Materialize (cost=7.58..645.12 rows=8 width=101) (actual time=0.000..0.122 rows=1,287 loops=767)

9. 0.742 8.941 ↓ 160.9 1,287 1

Nested Loop (cost=7.58..645.08 rows=8 width=101) (actual time=0.114..8.941 rows=1,287 loops=1)

10. 0.356 5.625 ↓ 160.9 1,287 1

Nested Loop (cost=7.29..578.66 rows=8 width=104) (actual time=0.108..5.625 rows=1,287 loops=1)

11. 0.105 2.695 ↓ 71.5 143 1

Nested Loop (cost=7.01..548.20 rows=2 width=104) (actual time=0.098..2.695 rows=143 loops=1)

12. 0.038 2.304 ↓ 71.5 143 1

Nested Loop (cost=6.71..546.94 rows=2 width=78) (actual time=0.090..2.304 rows=143 loops=1)

13. 0.015 0.015 ↑ 1.0 1 1

Index Only Scan using turma_pkey on turma turma_mptd (cost=0.29..4.30 rows=1 width=4) (actual time=0.014..0.015 rows=1 loops=1)

  • Index Cond: (codigo = 16149)
  • Heap Fetches: 0
14. 0.076 2.251 ↓ 71.5 143 1

Nested Loop (cost=6.43..542.62 rows=2 width=78) (actual time=0.067..2.251 rows=143 loops=1)

15. 0.116 1.889 ↓ 71.5 143 1

Nested Loop (cost=6.15..526.02 rows=2 width=40) (actual time=0.060..1.889 rows=143 loops=1)

16. 0.071 0.629 ↓ 71.5 143 1

Nested Loop (cost=5.86..525.35 rows=2 width=33) (actual time=0.035..0.629 rows=143 loops=1)

17. 0.112 0.129 ↓ 71.5 143 1

Bitmap Heap Scan on matriculaperiodoturmadisciplina (cost=5.44..508.48 rows=2 width=21) (actual time=0.026..0.129 rows=143 loops=1)

  • Recheck Cond: (turma = 16149)
  • Filter: (((ano)::text = '2020'::text) AND ((semestre)::text = '1'::text))
  • Heap Blocks: exact=23
18. 0.017 0.017 ↓ 1.1 143 1

Bitmap Index Scan on matriculaperiodoturmadisciplina_turma_disciplina_matricula (cost=0.00..5.44 rows=135 width=0) (actual time=0.017..0.017 rows=143 loops=1)

  • Index Cond: (turma = 16149)
19. 0.429 0.429 ↑ 1.0 1 143

Index Scan using matriculaperiodo_pkey on matriculaperiodo (cost=0.42..8.44 rows=1 width=16) (actual time=0.003..0.003 rows=1 loops=143)

  • Index Cond: (codigo = matriculaperiodoturmadisciplina.matriculaperiodo)
20. 1.144 1.144 ↑ 1.0 1 143

Index Scan using matricula_pkey on matricula (cost=0.29..0.33 rows=1 width=16) (actual time=0.008..0.008 rows=1 loops=143)

  • Index Cond: ((matricula)::text = (matriculaperiodo.matricula)::text)
21. 0.286 0.286 ↑ 1.0 1 143

Index Scan using disciplina_pkey on disciplina (cost=0.28..8.30 rows=1 width=38) (actual time=0.002..0.002 rows=1 loops=143)

  • Index Cond: (codigo = matriculaperiodoturmadisciplina.disciplina)
22. 0.286 0.286 ↑ 1.0 1 143

Index Scan using pessoa_pkey on pessoa (cost=0.29..0.63 rows=1 width=30) (actual time=0.002..0.002 rows=1 loops=143)

  • Index Cond: (codigo = matricula.aluno)
23. 1.001 2.574 ↓ 2.2 9 143

Append (cost=0.29..15.19 rows=4 width=4) (actual time=0.002..0.018 rows=9 loops=143)

24. 0.286 0.286 ↑ 1.0 1 143

Index Only Scan using turma_pkey on turma turma_1 (cost=0.29..4.30 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=143)

  • Index Cond: (codigo = matriculaperiodoturmadisciplina.turma)
  • Heap Fetches: 0
25. 0.858 1.287 ↓ 2.7 8 143

Bitmap Heap Scan on turmaagrupada (cost=4.30..10.83 rows=3 width=4) (actual time=0.005..0.009 rows=8 loops=143)

  • Recheck Cond: (turma = matriculaperiodoturmadisciplina.turma)
  • Heap Blocks: exact=715
26. 0.429 0.429 ↓ 2.7 8 143

Bitmap Index Scan on idx_turmaagrupada_turma (cost=0.00..4.30 rows=3 width=0) (actual time=0.003..0.003 rows=8 loops=143)

  • Index Cond: (turma = matriculaperiodoturmadisciplina.turma)
27. 2.574 2.574 ↑ 1.0 1 1,287

Index Scan using turma_pkey on turma (cost=0.29..8.30 rows=1 width=5) (actual time=0.002..0.002 rows=1 loops=1,287)

  • Index Cond: (codigo = turma_1.codigo)
28.          

SubPlan (for Nested Loop)

29. 7,897.032 7,897.032 ↓ 0.0 0 877,448

Seq Scan on disciplinaequivalente (cost=0.00..2.40 rows=1 width=4) (actual time=0.009..0.009 rows=0 loops=877,448)

  • Filter: (disciplina = atividadediscursiva.disciplina)
  • Rows Removed by Filter: 112
30. 3.840 3.840 ↓ 0.0 0 1,280

Index Scan using unique_atividadediscursiva_matriculaperiodoturmadisciplina on atividadediscursivarespostaaluno (cost=0.29..8.31 rows=1 width=29) (actual time=0.003..0.003 rows=0 loops=1,280)

  • Index Cond: ((atividadediscursiva = atividadediscursiva.codigo) AND (matriculaperiodoturmadisciplina = matriculaperiodoturmadisciplina.codigo))
31. 2.560 2.560 ↑ 1.0 1 1,280

Index Scan using turma_pkey on turma turmaavaliacao (cost=0.29..2.79 rows=1 width=27) (actual time=0.002..0.002 rows=1 loops=1,280)

  • Index Cond: (codigo = atividadediscursiva.turma)
32. 0.000 0.000 ↑ 1.0 7 1,280

Materialize (cost=0.00..1.10 rows=7 width=23) (actual time=0.000..0.000 rows=7 loops=1,280)

33. 0.012 0.012 ↑ 1.0 7 1

Seq Scan on calendarioatividadematricula (cost=0.00..1.07 rows=7 width=23) (actual time=0.010..0.012 rows=7 loops=1)

34.          

SubPlan (for Nested Loop Left Join)

35. 1.280 1.280 ↑ 1.0 1 1,280

Aggregate (cost=8.31..8.32 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=1,280)

36. 0.000 0.000 ↓ 0.0 0 1,280

Index Scan using ch_atividadediscursivainteracao_atividadediscursivarespostaalun on atividadediscursivainteracao (cost=0.29..8.30 rows=1 width=4) (actual time=0.000..0.000 rows=0 loops=1,280)

  • Index Cond: (atividadediscursivarespostaaluno = atividadediscursivarespostaaluno.codigo)
  • Filter: ((NOT interacaojalida) AND ((interagidopor)::text = 'PROFESSOR'::text))
Planning time : 5.818 ms
Execution time : 12,300.861 ms