Change the SQL subquery aliases to match layer names

This makes it easier when reviewing patches, since often the id appears
too far away from the query to make it into the diff. Also useful when
looking at e.g. pg_stat_activity