Class RecordQueryPlanner
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.RecordQueryPlanner
-
- All Implemented Interfaces:
QueryPlanner
@API(STABLE) public class RecordQueryPlanner extends Object implements QueryPlanner
The query planner. Query planning means converting aRecordQuery
to aRecordQueryPlan
. The plan can use secondary indexes defined in aRecordMetaData
to execute the query efficiently.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
RecordQueryPlanner.ScoredPlan
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.query.plan.QueryPlanner
QueryPlanner.IndexScanPreference
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_COMPLEXITY_THRESHOLD
A limit on the complexity of the plans generated by the planner.
-
Constructor Summary
Constructors Constructor Description RecordQueryPlanner(RecordMetaData metaData, RecordStoreState recordStoreState)
RecordQueryPlanner(RecordMetaData metaData, RecordStoreState recordStoreState, StoreTimer timer)
RecordQueryPlanner(RecordMetaData metaData, RecordStoreState recordStoreState, StoreTimer timer, int complexityThreshold)
RecordQueryPlanner(RecordMetaData metaData, RecordStoreState recordStoreState, PlannableIndexTypes indexTypes, StoreTimer timer)
RecordQueryPlanner(RecordMetaData metaData, RecordStoreState recordStoreState, PlannableIndexTypes indexTypes, StoreTimer timer, int complexityThreshold)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RecordQueryPlannerConfiguration
getConfiguration()
QueryPlanner.IndexScanPreference
getIndexScanPreference()
Get whetherRecordQueryIndexPlan
is preferred overRecordQueryScanPlan
even when it does not satisfy any additional conditions.RecordQueryPlan
plan(RecordQuery query)
Create a plan to get the results of the provided query.RecordQueryPlan
planCoveringAggregateIndex(RecordQuery query, Index index, KeyExpression indexExpr)
RecordQueryPlan
planCoveringAggregateIndex(RecordQuery query, String indexName)
void
setConfiguration(RecordQueryPlannerConfiguration configuration)
Set theRecordQueryPlannerConfiguration
for this planner.void
setIndexScanPreference(QueryPlanner.IndexScanPreference indexScanPreference)
Set whetherRecordQueryIndexPlan
is preferred overRecordQueryScanPlan
even when it does not satisfy any additional conditions.
-
-
-
Field Detail
-
DEFAULT_COMPLEXITY_THRESHOLD
public static final int DEFAULT_COMPLEXITY_THRESHOLD
A limit on the complexity of the plans generated by the planner. If the planner generates a query plan that exceeds this complexity, an exception will be thrown. SeeRecordQueryPlan.getComplexity()
for a description of plan complexity.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RecordQueryPlanner
public RecordQueryPlanner(@Nonnull RecordMetaData metaData, @Nonnull RecordStoreState recordStoreState)
-
RecordQueryPlanner
public RecordQueryPlanner(@Nonnull RecordMetaData metaData, @Nonnull RecordStoreState recordStoreState, @Nullable StoreTimer timer)
-
RecordQueryPlanner
public RecordQueryPlanner(@Nonnull RecordMetaData metaData, @Nonnull RecordStoreState recordStoreState, @Nonnull PlannableIndexTypes indexTypes, @Nullable StoreTimer timer)
-
RecordQueryPlanner
public RecordQueryPlanner(@Nonnull RecordMetaData metaData, @Nonnull RecordStoreState recordStoreState, @Nullable StoreTimer timer, int complexityThreshold)
-
RecordQueryPlanner
public RecordQueryPlanner(@Nonnull RecordMetaData metaData, @Nonnull RecordStoreState recordStoreState, @Nonnull PlannableIndexTypes indexTypes, @Nullable StoreTimer timer, int complexityThreshold)
-
-
Method Detail
-
getIndexScanPreference
@Nonnull public QueryPlanner.IndexScanPreference getIndexScanPreference()
Get whetherRecordQueryIndexPlan
is preferred overRecordQueryScanPlan
even when it does not satisfy any additional conditions.- Returns:
- whether to prefer index scan over record scan
-
setIndexScanPreference
public void setIndexScanPreference(@Nonnull QueryPlanner.IndexScanPreference indexScanPreference)
Set whetherRecordQueryIndexPlan
is preferred overRecordQueryScanPlan
even when it does not satisfy any additional conditions. Scanning without an index is more efficient, but will have to skip over unrelated record types. For that reason, it is safer to use an index, except when there is only one record type. If the meta-data has more than one record type but the record store does not, this can be overridden. If aRecordQueryPlannerConfiguration
is already set usingsetConfiguration(RecordQueryPlannerConfiguration)
(RecordQueryPlannerConfiguration)} it will be retained, but theIndexScanPreference
for the configuration will be replaced with the given preference.- Specified by:
setIndexScanPreference
in interfaceQueryPlanner
- Parameters:
indexScanPreference
- whether to prefer index scan over record scan
-
setConfiguration
public void setConfiguration(@Nonnull RecordQueryPlannerConfiguration configuration)
Set theRecordQueryPlannerConfiguration
for this planner. If anQueryPlanner.IndexScanPreference
is already set usingsetIndexScanPreference(IndexScanPreference)
then it will be ignored.- Parameters:
configuration
- a configuration object for this planner
-
getConfiguration
@Nonnull public RecordQueryPlannerConfiguration getConfiguration()
-
plan
@Nonnull public RecordQueryPlan plan(@Nonnull RecordQuery query)
Create a plan to get the results of the provided query.- Specified by:
plan
in interfaceQueryPlanner
- Parameters:
query
- a query for records on this planner's metadata- Returns:
- a plan that will return the results of the provided query when executed
- Throws:
RecordCoreException
- if there is no index that matches the sort in the provided query
-
planCoveringAggregateIndex
@Nullable public RecordQueryPlan planCoveringAggregateIndex(@Nonnull RecordQuery query, @Nonnull String indexName)
-
planCoveringAggregateIndex
@Nullable public RecordQueryPlan planCoveringAggregateIndex(@Nonnull RecordQuery query, @Nonnull Index index, @Nonnull KeyExpression indexExpr)
-
-