break latest versions query into N selects

doing a massive order by on every column is expensive, especially as
some inputs may have a disproportionate amount of versions, unrestrained
(i.e. a timing interval input with no passed: constraint).

this changes it to select one versioned resource at a time, ordered by
just its own id (descending), which allows the database to short-circuit
and not care about the other columns. as versioned resources are chosen,
their IDs are added as constraints for the later fetches, ensuring
that they're in a valid set.

also rolled back some optimizations that only helped in local testing.
benchmarking this locally is hard, as the real performance you care
about is after the database (i.e. postgres) has cached things and
analyzed the data.

[finishes #76644016]