add warnings, optimize query.group