Reduce the number of SQL queries
Reduce the number of SQL queries

Instead of fetching instance rows in one query, then passing them to
another query, use a subquery to fetch only the IDs in a WHERE caluse.
The database's query planner might do useful things with this.

GADS::Layout::cols_db() is called by GADS::Layout::columns() which is
called often throughout the code.

ctrlo/GADS,ctrlo/GADS,ctrlo/GADS,ctrlo/GADS,ctrlo/GADS