I have a Postgres table where the PK is made up of a UUID (id) and an integer (version). Most queries want to select the latest version of a particular ID. The query I use now looks like this:
select * from dataset
where id = '0faa6a7b-587c-4106-9b1e-3cf155c2ee41' and
version = (select max(version) from dataset where id = '0faa6a7b-587c-4106-9b1e-3cf155c2ee41')
I am wondering if there is a better, more efficient way of handling this type of query.