Wells Oliver <wells.oliver@xxxxxxxxx> writes: > PG 13.4. Can't quite run the EXPLAIN ANALYZE since it takes so long, but > EXPLAIN SELECT DISTINCT game_id FROM vw_joints shows (s = joints, p = plays) I doubt you're going to get a query plan that's significantly better than what you show here. But those tables are pretty large, so I wonder whether you have cranked up work_mem. One potential issue is that the planner thinks there are only about 1829 distinct game_id values: > HashAggregate (cost=63810150.11..63810168.40 rows=1829 width=4) > Group Key: p.game_id Is that about the right size of result for this? regards, tom lane