Replace metadata joins with another query

Right now, we always join metadata and system_metadata when we query for
instances. This inflates the number of rows returned by a factor of ten
at a minimum, and over 30 in some situations. This patch avoids the
direct join of these tables in favor of a "manual join" which performs
additional queries to fill the needed data. Latency may be increased,
but with the gain of a potentially significant amount of reduction in
data transfer.

This also provides the ability for the queries which utilize it to
selectively decide whether either or both of these additional fills are
performed, paving the way for future high-level optimizations.

Related to bug 1164737

(cherry-picked from c3568f9a1a28b269d88d2dcc175e6b5a2f7abf37)
Change-Id: I0610fb16ccce2ee95c318589c8abcc30613a3fe9
Don't join metadata twice in instance_get_all()

(cherry-picked from 842a6ac97b508b01f4773c94e8eb9416f997472e)
Change-Id: I2952243b093cda3d397f239ebe0db19246443a00
Merge "Replace metadata joins with another query" into stable/grizzly
Merge "Don't join metadata twice in instance_get_all()" into stable/grizzly