QUERY PLAN Sort (cost=41235.33..41386.96 rows=60652 width=65) (actual time=310.160..311.069 rows=25680 loops=1) Sort Key: sem.student_id, sem.semester Sort Method: quicksort Memory: 3546kB -> Hash Join (cost=17188.20..36417.05 rows=60652 width=65) (actual time=120.278..277.411 rows=25680 loops=1) Hash Cond: (sem.student_id = s.student_id) -> Nested Loop (cost=16161.52..30416.22 rows=698820 width=69) (actual time=114.485..251.311 rows=199740 loops=1) -> HashAggregate (cost=16161.52..16183.00 rows=2148 width=4) (actual time=114.447..117.146 rows=9987 loops=1) -> Seq Scan on student_semester s2 (cost=0.00..16054.25 rows=42908 width=4) (actual time=0.015..107.698 rows=42331 loops=1) Filter: ((college)::text = 'AS'::text) -> Index Scan using student_id_index on student_semester sem (cost=0.00..6.38 rows=20 width=65) (actual time=0.003..0.011 rows=20 loops=9987) Index Cond: (student_id = s2.student_id) -> Hash (cost=988.73..988.73 rows=3036 width=4) (actual time=5.677..5.677 rows=3026 loops=1) Buckets: 1024 Batches: 1 Memory Usage: 107kB -> Bitmap Heap Scan on student s (cost=71.78..988.73 rows=3036 width=4) (actual time=0.926..4.008 rows=3026 loops=1) Recheck Cond: (entryyear = 2006) -> Bitmap Index Scan on student_act_sat_entryyear_index (cost=0.00..71.03 rows=3036 width=0) (actual time=0.856..0.856 rows=3026 loops=1) Index Cond: (entryyear = 2006) Total runtime: 312.338 ms