QUERY PLAN Sort (cost=41131.44..41283.07 rows=60652 width=65) (actual time=372.948..373.814 rows=25680 loops=1) Sort Key: sem.student_id, sem.semester Sort Method: quicksort Memory: 3546kB -> Hash Join (cost=17031.82..36313.16 rows=60652 width=65) (actual time=137.830..340.942 rows=25680 loops=1) Hash Cond: (sem.student_id = s.student_id) -> Seq Scan on student_semester sem (cost=0.00..14307.20 rows=698820 width=65) (actual time=0.038..152.953 rows=698820 loops=1) -> Hash (cost=16993.87..16993.87 rows=3036 width=8) (actual time=137.756..137.756 rows=1284 loops=1) Buckets: 1024 Batches: 1 Memory Usage: 51kB -> Nested Loop (cost=16161.52..16993.87 rows=3036 width=8) (actual time=116.728..137.407 rows=1284 loops=1) -> HashAggregate (cost=16161.52..16183.00 rows=2148 width=4) (actual time=116.650..118.613 rows=9987 loops=1) -> Seq Scan on student_semester s2 (cost=0.00..16054.25 rows=42908 width=4) (actual time=0.035..109.371 rows=42331 loops=1) Filter: ((collgs)::text = 'AS'::text) -> Index Scan using student_id_pkey on student s (cost=0.00..0.36 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=9987) Index Cond: (student_id = s2.student_id) Filter: (entryyear = 2006) Total runtime: 375.068 ms