Return queries grouped by associated database.