This is a query in a two-dimensional loop. At least get all inner types at once?