Speed up max-group-by query using loose index scan

https://wiki.postgresql.org/wiki/Loose_indexscan