explain.depesz.com

PostgreSQL's explain analyze made readable

Result: EQkd

Settings
# exclusive inclusive rows x rows loops node
1. 0.015 152.331 ↓ 12.0 12 1

Unique (cost=14,466.58..14,466.61 rows=1 width=165) (actual time=152.317..152.331 rows=12 loops=1)

2. 0.057 152.316 ↓ 12.0 12 1

Sort (cost=14,466.58..14,466.58 rows=1 width=165) (actual time=152.315..152.316 rows=12 loops=1)

  • Sort Key: turma.identificadorturma, curso.nome, disciplina.nome, arquivo.descricaoarquivo, arquivo.datadisponibilizacao, professor.nome, turma.codigo, curso.codigo, disciplina.codigo, professor.codigo
  • Sort Method: quicksort Memory: 28kB
3. 0.014 152.259 ↓ 12.0 12 1

Nested Loop Left Join (cost=8,889.03..14,466.57 rows=1 width=165) (actual time=83.640..152.259 rows=12 loops=1)

4. 0.019 152.245 ↓ 12.0 12 1

Nested Loop Left Join (cost=8,888.76..14,466.24 rows=1 width=117) (actual time=83.635..152.245 rows=12 loops=1)

5. 0.017 152.190 ↓ 12.0 12 1

Nested Loop Left Join (cost=8,888.34..14,460.08 rows=1 width=92) (actual time=83.621..152.190 rows=12 loops=1)

6. 7.993 152.125 ↓ 12.0 12 1

Merge Left Join (cost=8,888.05..14,459.73 rows=1 width=83) (actual time=83.595..152.125 rows=12 loops=1)

  • Merge Cond: (arquivo.disciplina = "*SELECT* 1".disciplina)
  • Filter: ((((("*SELECT* 1".anovigente)::text = ''::text) AND (("*SELECT* 1".semestrevigente)::text = ''::text) AND (NOT arquivo.manterdisponibilizacao)) OR arquivo.manterdisponibilizacao) AND ((arquivo.disciplina = 3726) OR (arquivo.disciplina = "*SELECT* 1".disciplina)) AND (((arquivo.turma IS NULL) AND (arquivo.professor IS NULL)) OR ((arquivo.professor IS NULL) AND (arquivo.turma = "*SELECT* 1".turma)) OR ((arquivo.professor = "*SELECT* 1".professor) AND (arquivo.turma = "*SELECT* 1".turma)) OR ((arquivo.professor = "*SELECT* 1".professor) AND (arquivo.turma IS NULL))))
  • Rows Removed by Filter: 34757
7. 14.478 129.393 ↓ 40.2 34,769 1

Merge Join (cost=0.94..5,570.42 rows=865 width=88) (actual time=0.048..129.393 rows=34,769 loops=1)

  • Merge Cond: (arquivo.disciplina = disciplina.codigo)
8. 112.871 112.871 ↓ 4.0 34,770 1

Index Scan using ch_arquivo_disciplina on arquivo (cost=0.42..52,813.26 rows=8,609 width=52) (actual time=0.031..112.871 rows=34,770 loops=1)

  • Filter: (((origem)::text = ANY ('{IN,PR}'::text[])) AND ((situacao)::text = 'AT'::text) AND (datadisponibilizacao <= CURRENT_TIMESTAMP) AND CASE WHEN ((NOT manterdisponibilizacao) AND (NOT apresentardeterminadoperiodo)) THEN false WHEN ((NOT manterdisponibilizacao) AND apresentardeterminadoperiodo) THEN ((dataindisponibilizacao >= CURRENT_TIMESTAMP) OR (dataindisponibilizacao IS NULL)) WHEN (manterdisponibilizacao AND (NOT apresentardeterminadoperiodo)) THEN true ELSE NULL::boolean END)
  • Rows Removed by Filter: 57672
9. 2.044 2.044 ↑ 1.0 5,266 1

Index Scan using disciplina_pkey on disciplina (cost=0.28..239.47 rows=5,309 width=48) (actual time=0.009..2.044 rows=5,266 loops=1)

10. 0.035 14.739 ↑ 2.0 1 1

Sort (cost=8,887.11..8,887.12 rows=2 width=14) (actual time=14.708..14.739 rows=1 loops=1)

  • Sort Key: "*SELECT* 1".disciplina
  • Sort Method: quicksort Memory: 25kB
11. 0.002 14.704 ↑ 2.0 1 1

Append (cost=8,821.37..8,887.10 rows=2 width=14) (actual time=14.575..14.704 rows=1 loops=1)

12. 0.002 14.578 ↑ 1.0 1 1

Subquery Scan on *SELECT* 1 (cost=8,821.37..8,821.40 rows=1 width=14) (actual time=14.574..14.578 rows=1 loops=1)

13. 0.004 14.576 ↑ 1.0 1 1

Unique (cost=8,821.37..8,821.39 rows=1 width=15) (actual time=14.573..14.576 rows=1 loops=1)

14. 0.017 14.572 ↓ 4.0 4 1

Sort (cost=8,821.37..8,821.38 rows=1 width=15) (actual time=14.572..14.572 rows=4 loops=1)

  • Sort Key: horarioturma.turma, turma_1.turmaagrupada, horarioturmadiaitem.disciplina, horarioturmadiaitem.professor, horarioturma.anovigente, horarioturma.semestrevigente
  • Sort Method: quicksort Memory: 25kB
15. 0.000 14.555 ↓ 4.0 4 1

Nested Loop (cost=7,977.67..8,821.36 rows=1 width=15) (actual time=14.335..14.555 rows=4 loops=1)

  • Join Filter: (((NOT turma_1.turmaagrupada) AND (horarioturmadiaitem.disciplina = 3726)) OR (turma_1.turmaagrupada AND (hashed SubPlan 1)))
16. 0.018 14.214 ↑ 3.4 57 1

Nested Loop (cost=7,970.20..8,034.32 rows=191 width=11) (actual time=14.169..14.214 rows=57 loops=1)

17. 0.002 14.157 ↑ 4.0 1 1

Nested Loop (cost=7,969.78..8,017.17 rows=4 width=11) (actual time=14.156..14.157 rows=1 loops=1)

18. 0.004 14.146 ↑ 6.0 1 1

Nested Loop (cost=7,969.50..8,015.14 rows=6 width=9) (actual time=14.145..14.146 rows=1 loops=1)

19. 0.008 14.130 ↑ 6.0 1 1

HashAggregate (cost=7,969.22..7,969.28 rows=6 width=4) (actual time=14.130..14.130 rows=1 loops=1)

  • Group Key: matriculaperiodoturmadisciplina.turmapratica
20. 0.002 14.122 ↑ 6.0 1 1

Append (cost=0.43..7,969.20 rows=6 width=4) (actual time=0.086..14.122 rows=1 loops=1)

21. 0.009 0.009 ↓ 0.0 0 1

Index Scan using idx_mptd_turmapratica on matriculaperiodoturmadisciplina (cost=0.43..8.45 rows=1 width=4) (actual time=0.009..0.009 rows=0 loops=1)

  • Index Cond: (turmapratica IS NOT NULL)
  • Filter: (((matricula)::text = '053DT0000656'::text) AND (disciplina = 3726))
22. 0.007 0.007 ↓ 0.0 0 1

Index Scan using idx_mptd_turmateorica on matriculaperiodoturmadisciplina matriculaperiodoturmadisciplina_1 (cost=0.43..8.45 rows=1 width=4) (actual time=0.006..0.007 rows=0 loops=1)

  • Index Cond: (turmateorica IS NOT NULL)
  • Filter: (((matricula)::text = '053DT0000656'::text) AND (disciplina = 3726))
23. 5.088 5.088 ↑ 1.0 1 1

Index Scan using unique_matriculaperiodoturmadisciplina_disc_matriculaperi_turma on matriculaperiodoturmadisciplina matriculaperiodoturmadisciplina_2 (cost=0.43..1,945.75 rows=1 width=4) (actual time=0.070..5.088 rows=1 loops=1)

  • Index Cond: (disciplina = 3726)
  • Filter: ((turmateorica IS NULL) AND (turmapratica IS NULL) AND ((matricula)::text = '053DT0000656'::text))
  • Rows Removed by Filter: 3013
24. 0.001 2.685 ↓ 0.0 0 1

Nested Loop (cost=0.71..2,002.15 rows=1 width=4) (actual time=2.685..2.685 rows=0 loops=1)

25. 0.002 2.684 ↓ 0.0 0 1

Nested Loop (cost=0.43..2,001.65 rows=1 width=4) (actual time=2.684..2.684 rows=0 loops=1)

  • Join Filter: (matriculaperiodoturmadisciplina_3.turmapratica = turmaagrupada.turma)
26. 2.676 2.676 ↑ 1.0 1 1

Index Scan using unique_matriculaperiodoturmadisciplina_disc_matriculaperi_turma on matriculaperiodoturmadisciplina matriculaperiodoturmadisciplina_3 (cost=0.43..1,945.75 rows=1 width=4) (actual time=0.036..2.676 rows=1 loops=1)

  • Index Cond: (disciplina = 3726)
  • Filter: ((matricula)::text = '053DT0000656'::text)
  • Rows Removed by Filter: 3013
27. 0.006 0.006 ↓ 0.0 0 1

Seq Scan on turmaagrupada (cost=0.00..30.40 rows=2,040 width=8) (actual time=0.006..0.006 rows=0 loops=1)

28. 0.000 0.000 ↓ 0.0 0

Index Scan using turma_pkey on turma turma_2 (cost=0.28..0.50 rows=1 width=4) (never executed)

  • Index Cond: (codigo = turmaagrupada.turmaorigem)
  • Filter: ((situacao)::text = 'AB'::text)
29. 0.000 2.691 ↓ 0.0 0 1

Nested Loop (cost=0.71..2,002.15 rows=1 width=4) (actual time=2.691..2.691 rows=0 loops=1)

30. 0.002 2.691 ↓ 0.0 0 1

Nested Loop (cost=0.43..2,001.65 rows=1 width=4) (actual time=2.691..2.691 rows=0 loops=1)

  • Join Filter: (matriculaperiodoturmadisciplina_4.turmateorica = turmaagrupada_1.turma)
31. 2.687 2.687 ↑ 1.0 1 1

Index Scan using unique_matriculaperiodoturmadisciplina_disc_matriculaperi_turma on matriculaperiodoturmadisciplina matriculaperiodoturmadisciplina_4 (cost=0.43..1,945.75 rows=1 width=4) (actual time=0.033..2.687 rows=1 loops=1)

  • Index Cond: (disciplina = 3726)
  • Filter: ((matricula)::text = '053DT0000656'::text)
  • Rows Removed by Filter: 3013
32. 0.002 0.002 ↓ 0.0 0 1

Seq Scan on turmaagrupada turmaagrupada_1 (cost=0.00..30.40 rows=2,040 width=8) (actual time=0.002..0.002 rows=0 loops=1)

33. 0.000 0.000 ↓ 0.0 0

Index Scan using turma_pkey on turma turma_3 (cost=0.28..0.50 rows=1 width=4) (never executed)

  • Index Cond: (codigo = turmaagrupada_1.turmaorigem)
  • Filter: ((situacao)::text = 'AB'::text)
34. 0.001 3.640 ↓ 0.0 0 1

Nested Loop (cost=0.71..2,002.15 rows=1 width=4) (actual time=3.640..3.640 rows=0 loops=1)

35. 0.001 3.639 ↓ 0.0 0 1

Nested Loop (cost=0.43..2,001.65 rows=1 width=4) (actual time=3.639..3.639 rows=0 loops=1)

  • Join Filter: (matriculaperiodoturmadisciplina_5.turma = turmaagrupada_2.turma)
36. 3.636 3.636 ↑ 1.0 1 1

Index Scan using unique_matriculaperiodoturmadisciplina_disc_matriculaperi_turma on matriculaperiodoturmadisciplina matriculaperiodoturmadisciplina_5 (cost=0.43..1,945.75 rows=1 width=4) (actual time=0.042..3.636 rows=1 loops=1)

  • Index Cond: (disciplina = 3726)
  • Filter: ((turmateorica IS NULL) AND (turmapratica IS NULL) AND ((matricula)::text = '053DT0000656'::text))
  • Rows Removed by Filter: 3013
37. 0.002 0.002 ↓ 0.0 0 1

Seq Scan on turmaagrupada turmaagrupada_2 (cost=0.00..30.40 rows=2,040 width=8) (actual time=0.002..0.002 rows=0 loops=1)

38. 0.000 0.000 ↓ 0.0 0

Index Scan using turma_pkey on turma turma_4 (cost=0.28..0.50 rows=1 width=4) (never executed)

  • Index Cond: (codigo = turmaagrupada_2.turmaorigem)
  • Filter: ((situacao)::text = 'AB'::text)
39. 0.012 0.012 ↑ 1.0 1 1

Index Scan using turma_pkey on turma turma_1 (cost=0.28..7.63 rows=1 width=5) (actual time=0.011..0.012 rows=1 loops=1)

  • Index Cond: (codigo = matriculaperiodoturmadisciplina.turmapratica)
40. 0.009 0.009 ↑ 1.0 1 1

Index Scan using ch_horarioturma_turma_ano_semestre on horarioturma (cost=0.28..0.33 rows=1 width=10) (actual time=0.009..0.009 rows=1 loops=1)

  • Index Cond: (turma = turma_1.codigo)
41. 0.039 0.039 ↓ 1.1 57 1

Index Scan using fk_horarioturmadia_horarioturma on horarioturmadia (cost=0.42..3.75 rows=54 width=8) (actual time=0.011..0.039 rows=57 loops=1)

  • Index Cond: (horarioturma = horarioturma.codigo)
42. 0.315 0.342 ↓ 0.0 0 57

Index Scan using idx_horturdiaitem_horturmdia on horarioturmadiaitem (cost=3.94..4.09 rows=1 width=12) (actual time=0.006..0.006 rows=0 loops=57)

  • Index Cond: (horarioturmadia = horarioturmadia.codigo)
  • Filter: ((disciplina = 3726) OR (hashed SubPlan 1))
  • Rows Removed by Filter: 1
43.          

SubPlan (forIndex Scan)

44. 0.003 0.027 ↑ 3.0 1 1

HashAggregate (cost=3.49..3.52 rows=3 width=4) (actual time=0.027..0.027 rows=1 loops=1)

  • Group Key: (3726)
45. 0.001 0.024 ↑ 3.0 1 1

Append (cost=0.00..3.48 rows=3 width=4) (actual time=0.002..0.024 rows=1 loops=1)

46. 0.001 0.001 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=1)

47. 0.014 0.014 ↓ 0.0 0 1

Seq Scan on disciplinaequivalente (cost=0.00..1.71 rows=1 width=4) (actual time=0.013..0.014 rows=0 loops=1)

  • Filter: (equivalente = 3726)
  • Rows Removed by Filter: 57
48. 0.008 0.008 ↓ 0.0 0 1

Seq Scan on disciplinaequivalente disciplinaequivalente_1 (cost=0.00..1.71 rows=1 width=4) (actual time=0.008..0.008 rows=0 loops=1)

  • Filter: (disciplina = 3726)
  • Rows Removed by Filter: 57
49. 0.000 0.124 ↓ 0.0 0 1

Subquery Scan on *SELECT* 2 (cost=1.00..65.69 rows=1 width=14) (actual time=0.124..0.124 rows=0 loops=1)

50. 0.000 0.124 ↓ 0.0 0 1

Nested Loop (cost=1.00..65.68 rows=1 width=15) (actual time=0.124..0.124 rows=0 loops=1)

51. 0.001 0.124 ↓ 0.0 0 1

Nested Loop (cost=0.57..58.10 rows=1 width=12) (actual time=0.124..0.124 rows=0 loops=1)

52. 0.123 0.123 ↓ 0.0 0 1

Index Scan using ch_turmadisciplina_disciplina on turmadisciplina (cost=0.29..49.80 rows=1 width=8) (actual time=0.123..0.123 rows=0 loops=1)

  • Index Cond: (disciplina = 3726)
  • Filter: ((definicoestutoriaonline)::text = 'DINAMICA'::text)
  • Rows Removed by Filter: 68
53. 0.000 0.000 ↓ 0.0 0

Index Only Scan using turma_pkey on turma turma_5 (cost=0.28..8.30 rows=1 width=4) (never executed)

  • Index Cond: (codigo = turmadisciplina.turma)
  • Heap Fetches: 0
54. 0.000 0.000 ↓ 0.0 0

Index Scan using matriculaperiodoturmadisciplina_turma_disciplina_matricula on matriculaperiodoturmadisciplina matriculaperiodoturmadisciplina_6 (cost=0.43..7.57 rows=1 width=14) (never executed)

  • Index Cond: ((turma = turma_5.codigo) AND (disciplina = 3726) AND ((matricula)::text = '053DT0000656'::text))
  • Filter: ((professor IS NOT NULL) AND ((modalidadedisciplina)::text = 'ON_LINE'::text))
55. 0.048 0.048 ↑ 1.0 1 12

Index Scan using turma_pkey on turma (cost=0.28..0.35 rows=1 width=13) (actual time=0.004..0.004 rows=1 loops=12)

  • Index Cond: (arquivo.turma = codigo)
56. 0.036 0.036 ↑ 1.0 1 12

Index Scan using pessoa_pkey on pessoa professor (cost=0.42..6.16 rows=1 width=29) (actual time=0.003..0.003 rows=1 loops=12)

  • Index Cond: (arquivo.professor = codigo)
57. 0.000 0.000 ↓ 0.0 0 12

Index Scan using curso_pkey on curso (cost=0.27..0.30 rows=1 width=52) (actual time=0.000..0.000 rows=0 loops=12)

  • Index Cond: (arquivo.curso = codigo)
Planning time : 9.204 ms
Execution time : 152.820 ms