Why is PostgreSQL sorting a seemingly already sorted result set? I’m trying to optimize the following query for a school assignment: