Realpath isn't used anymore.
Postgres requires you to include the GROUP BY column in the SELECT columns. Should be okay since we don't care about other columns though.