private SelectResults applyProjectionOnCollection(SelectResults resultSet,
      ExecutionContext context, boolean ignoreOrderBy) throws TypeMismatchException,
      FunctionDomainException, NameResolutionException, QueryInvocationTargetException {
    List iterators = context.getCurrentIterators();
    if (projAttrs == null && (orderByAttrs == null || ignoreOrderBy)) {
      // If the projection attribute is null (ie specified as *) & there is only one Runtime
      // Iterator we can return the set as it is. But if the projection attribute is null & multiple
      // Iterators are defined we need to rectify the StructBag that is returned. It is to be noted
      // that in case of single from clause where the from clause itself is defined as nested select
      // query with multiple from clauses, the result set returned will be a StructBag which we have
      // to return as it is.
      if (iterators.size() > 1) {
        StructType type = createStructTypeForNullProjection(iterators, context);
        resultSet.setElementType(type);
      }

      return resultSet;
    } else {
      int numElementsAdded = 0;
      SelectResults pResultSet = prepareEmptyResultSet(context, ignoreOrderBy);
      boolean isStructType = resultSet.getCollectionType().getElementType() != null
          && resultSet.getCollectionType().getElementType().isStructType();
      if (isStructType) {
        Iterator resultsIter = resultSet.iterator();
        // Apply limit if there is no order by
        Integer limitValue = evaluateLimitValue(context, limit);
        while (((orderByAttrs != null && !ignoreOrderBy) || limitValue < 0
            || (numElementsAdded < limitValue)) && resultsIter.hasNext()) {
          // Check if query execution on this thread is canceled
          QueryMonitor.throwExceptionIfQueryOnCurrentThreadIsCanceled();

          Object[] values = ((Struct) resultsIter.next()).getFieldValues();
          for (int i = 0; i < values.length; i++) {
            ((RuntimeIterator) iterators.get(i)).setCurrent(values[i]);
          }
          int occurrence = applyProjectionAndAddToResultSet(context, pResultSet, ignoreOrderBy);
          if (occurrence == 1 || (occurrence > 1 && !distinct)) {
            // (Unique i.e first time occurrence) or subsequent occurrence
            // for non distinct query
            ++numElementsAdded;
          }
        }
        // return pResultSet;
      } else if (iterators.size() == 1) {
        RuntimeIterator rIter = (RuntimeIterator) iterators.get(0);
        Iterator resultsIter = resultSet.iterator();
        // Apply limit if there is no order by.
        Integer limitValue = evaluateLimitValue(context, limit);
        while (((orderByAttrs != null && !ignoreOrderBy) || limitValue < 0
            || (numElementsAdded < limitValue)) && resultsIter.hasNext()) {
          rIter.setCurrent(resultsIter.next());
          int occurrence = applyProjectionAndAddToResultSet(context, pResultSet, ignoreOrderBy);
          if (occurrence == 1 || (occurrence > 1 && !distinct)) {
            // (Unique i.e first time occurrence) or subsequent occurrence
            // for non distinct query
            ++numElementsAdded;
          }
        }
      } else {
        throw new RuntimeException(
            "Result Set does not match with iterator definitions in from clause");
      }
      return pResultSet;
    }
  }
Check for the bulk-get pattern and if it applies do an optimized execution. The pattern is:
SELECT ?? FROM <Region>.entrySet e WHERE e.key IN <Collection>.

@return a List of entries if optimization was executed, or null if it wasn't because the
        optimization pattern didn't match
geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledSelect.java