Move subselects into the main pager query

This saves a few thousand round-trips to the db cluster...

Change-Id: Ib7834cb3d49b7f02bdabfc5512ff075c40139a9c
Merge "Move subselects into the main pager query"