Query behavior (sorting and limits)
book
Article ID: KB0074908
calendar_today
Updated On:
Description
How does StreamBase handle Query operator Where expressions in the context of sorting and limits? For example, suppose I specify the Where expression
(NonIndexedField1 == 1 || NonIndexedField2 == 2) && (PrimaryIndexField > 10)
and set the following properties on the Query Operator's Query tab:
Order:
by Primary IndexLimit:
20How will the StreamBase CEP runtime perform this query? Specifically:
- Will a table scan be performed since the first part of the expression evaluates non-indexed fields?
- Will the Query operation stop when it finds 20 results (as specified in the Query Operator's Limit property), or will it find all matching results, sort them, and then return only the specified number of results?
Resolution
- No, a table scan will not be performed. The order of fields used in the expression does not affect whether a table scan will be performed.
- Yes, the query operation will stop when it reaches 20 results. The query is pre-sorted based on the Primary Index (as specified in the Query Operator's Order property), thus evaluating the range bound should provide satisfactory performance.
This was confirmed using StreamBase 7.2.
Issue/Introduction
Query behavior (sorting and limits)
Feedback
thumb_up
Yes
thumb_down
No