explain.depesz.com

PostgreSQL's explain analyze made readable

Result: YylG

Settings
# exclusive inclusive rows x rows loops node
1. 0.226 1,180.769 ↑ 5.7 10 1

Unique (cost=4,916.66..4,918.08 rows=57 width=69) (actual time=1,180.511..1,180.769 rows=10 loops=1)

2. 0.987 1,180.543 ↓ 8.4 480 1

Sort (cost=4,916.66..4,916.80 rows=57 width=69) (actual time=1,180.510..1,180.543 rows=480 loops=1)

  • Sort Key: horarioturma.codigo, turmaagrupada.turma, t.subturma, t.tiposubturma, t.turmaagrupada, horarioturmadiaitem.disciplina, horarioturma.anovigente, horarioturma.semestrevigente, horarioturma.turma
  • Sort Method: quicksort Memory: 92kB
3. 117.291 1,179.556 ↓ 8.4 480 1

Nested Loop (cost=266.46..4,915.00 rows=57 width=69) (actual time=488.030..1,179.556 rows=480 loops=1)

  • Join Filter: ((t.semestral AND ((horarioturma.anovigente)::text = '2020'::text) AND ((horarioturma.semestrevigente)::text = '2'::text)) OR (t.anual AND ((horarioturma.anovigente)::text = '2020'::text)) OR ((NOT t.semestral) AND (NOT t.anual) AND (horarioturmadiaitem.data >= (CURRENT_DATE - '1 year'::interval))))
  • Rows Removed by Join Filter: 10,572
4. 20.507 202.665 ↓ 8.8 61,400 1

Nested Loop (cost=266.04..798.38 rows=7,010 width=31) (actual time=74.751..202.665 rows=61,400 loops=1)

5. 3.606 80.161 ↓ 24.0 4,857 1

Hash Join (cost=265.62..365.85 rows=202 width=27) (actual time=74.735..80.161 rows=4,857 loops=1)

  • Hash Cond: (turmaagrupada.turmaorigem = t.codigo)
6. 1.836 1.836 ↑ 1.0 5,106 1

Seq Scan on turmaagrupada (cost=0.00..79.06 rows=5,106 width=8) (actual time=0.008..1.836 rows=5,106 loops=1)

7. 0.175 74.719 ↓ 2.6 607 1

Hash (cost=262.72..262.72 rows=232 width=27) (actual time=74.716..74.719 rows=607 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 45kB
8. 72.690 74.544 ↓ 2.6 607 1

Hash Join (cost=202.25..262.72 rows=232 width=27) (actual time=1.614..74.544 rows=607 loops=1)

  • Hash Cond: (horarioturma.turma = t.codigo)
9. 0.254 0.254 ↑ 1.0 2,967 1

Seq Scan on horarioturma (cost=0.00..52.67 rows=2,967 width=13) (actual time=0.005..0.254 rows=2,967 loops=1)

10. 0.093 1.600 ↓ 1.4 630 1

Hash (cost=196.53..196.53 rows=458 width=14) (actual time=1.599..1.600 rows=630 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 37kB
11. 1.507 1.507 ↓ 1.4 630 1

Seq Scan on turma t (cost=0.00..196.53 rows=458 width=14) (actual time=0.016..1.507 rows=630 loops=1)

  • Filter: (turmaagrupada AND (NOT subturma) AND (semestral OR anual OR ((NOT semestral) AND (NOT anual))))
  • Rows Removed by Filter: 5,223
12. 101.997 101.997 ↑ 2.9 13 4,857

Index Scan using fk_horarioturmadia_horarioturma on horarioturmadia (cost=0.42..1.76 rows=38 width=8) (actual time=0.003..0.021 rows=13 loops=4,857)

  • Index Cond: (horarioturma = horarioturma.codigo)
13. 859.600 859.600 ↓ 0.0 0 61,400

Index Scan using horarioturmadiaitem_uniq on horarioturmadiaitem (cost=0.42..0.56 rows=1 width=16) (actual time=0.014..0.014 rows=0 loops=61,400)

  • Index Cond: (horarioturmadia = horarioturmadia.codigo)
  • Filter: (professor = 9,959)
  • Rows Removed by Filter: 4
Planning time : 1.382 ms
Execution time : 1,180.825 ms