private SelectResults prepareEmptyResultSet(ExecutionContext context, boolean ignoreOrderBy)
      throws TypeMismatchException, AmbiguousNameException {
    // If no projection attributes or '*' as projection attribute & more than one/RunTimeIterator
    // then create a StructSet.
    // If attribute is null or '*' & only one RuntimeIterator then create a ResultSet.
    // If single attribute is present without alias name, then create ResultSet.
    // Else if more than on attribute or single attribute with alias is present then return a
    // StructSet.
    // Create StructSet which will contain root objects of all iterators in from clause.
    ObjectType elementType = cachedElementTypeForOrderBy != null
        ? cachedElementTypeForOrderBy : prepareResultType(context);
    SelectResults results;

    if (!distinct && count) {
      // Shobhit: If it's a 'COUNT' query and no End processing required Like for 'DISTINCT'
      // we can directly keep count in ResultSet and ResultBag is good enough for that.
      results = new ResultsBag(new ObjectTypeImpl(Integer.class), 1, context.getCachePerfStats());
      countStartQueryResult = 0;
      return results;
    }

    // Potential edge-case: Could this be non-null but empty?
    boolean nullValuesAtStart = orderByAttrs != null && !orderByAttrs.get(0).getCriterion();
    OrderByComparator comparator;
    boolean isOrdered = orderByAttrs != null;

    switch (DataContainerType.determineDataContainerType(isOrdered, distinct,
        elementType.isStructType(), ignoreOrderBy)) {
      case UNORDERED_DISTINCT_STRUCT:
        return new StructSet((StructType) elementType);
      case UNORDERED_DISTINCT_RESULTS:
        return new ResultsSet(elementType);
      case UNORDERED_INDISTINCT_STRUCT:
        return new StructBag((StructType) elementType, context.getCachePerfStats());
      case UNORDERED_INDISTINCT_RESULTS:
        return new ResultsBag(elementType, context.getCachePerfStats());

      case ORDERED_DISTINCT_STRUCT_IGNORED:
        return new LinkedStructSet((StructTypeImpl) elementType);
      case ORDERED_INDISTINCT_STRUCT_IGNORED:
        return new SortedResultsBag(elementType, nullValuesAtStart);
      case ORDERED_DISTINCT_STRUCT_UNIGNORED:
        comparator = hasUnmappedOrderByCols
            ? new OrderByComparatorMapped(orderByAttrs, elementType, context)
            : new OrderByComparator(orderByAttrs, elementType, context);
        return new SortedStructSet(comparator, (StructTypeImpl) elementType);
      case ORDERED_INDISTINCT_STRUCT_UNIGNORED:
        comparator = hasUnmappedOrderByCols
            ? new OrderByComparatorMapped(orderByAttrs, elementType, context)
            : new OrderByComparator(orderByAttrs, elementType, context);
        return new SortedStructBag(comparator, (StructType) elementType, nullValuesAtStart);
      case ORDERED_DISTINCT_RESULTS_IGNORED:
        results = new LinkedResultSet();
        results.setElementType(elementType);
        return results;
      case ORDERED_INDISTINCT_RESULTS_IGNORED:
        results = new SortedResultsBag(nullValuesAtStart);
        results.setElementType(elementType);
        return results;
      case ORDERED_DISTINCT_RESULTS_UNIGNORED:
        comparator = hasUnmappedOrderByCols
            ? new OrderByComparatorMapped(orderByAttrs, elementType, context)
            : new OrderByComparator(orderByAttrs, elementType, context);
        results = new SortedResultSet(comparator);
        results.setElementType(elementType);
        return results;
      case ORDERED_INDISTINCT_RESULTS_UNIGNORED:
        comparator = hasUnmappedOrderByCols
            ? new OrderByComparatorMapped(orderByAttrs, elementType, context)
            : new OrderByComparator(orderByAttrs, elementType, context);
        results = new SortedResultsBag(comparator, nullValuesAtStart);
        results.setElementType(elementType);
        return results;
    }
    throw new TypeMismatchException("Logical inconsistency in CompiledSelect");
  }
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