Use resultSet array length for total match count

This fixes #8726.