Skip to content

Latest commit

 

History

History
31 lines (19 loc) · 2.1 KB

MergeStrategies.md

File metadata and controls

31 lines (19 loc) · 2.1 KB

CQEngine Merge Strategies

Merge strategies are the algorithms CQEngine uses to evaluate queries which have multiple branches.

Merge strategy: default

By default, CQEngine's algorithm to evaluate queries, is to use indexes to locate the smallest candidate set of objects, and then to use on-the-fly filtering to reduce the candidate set to the final set of objects which match the query.

To perform filtering, this strategy asks the attributes referenced in the query, to return the value of that attribute from each candidate object.

Generally speaking, this provides best performance when the objects from which attributes read the values, are already in memory on the Java heap. Typically this is the case when the IndexedCollection is located on-heap.

However, this strategy can be expensive when objects from which attributes read the values are located off-heap or on disk, because it is usually necessary to deserialize the candidate objects in order to read their values.

Merge strategy: index

The "index" merge strategy uses indexes to locate the smallest candidate set of objects, however instead of asking the attributes to return values from the candidate objects, it evaluates the query by performing joins between indexes on-the-fly instead.

Only the final set of objects which actually match the query, will be deserialized; and lazily as the application requests them.

Generally speaking, this provides best performance when the objects from which attributes read the values, are not stored on the Java heap. Typically this is the case when the IndexedCollection is located off-heap, or on disk.

This strategy can be requested by supplying query option EngineFlags.PREFER_INDEX_MERGE_STRATEGY.

Note this strategy requires that indexes are available for all of the attributes referenced in a query. If required indexes are not available, the default merge strategy will be used instead.