Query behavior (sorting and limits)

Query behavior (sorting and limits)

book

Article ID: KB0074908

calendar_today

Updated On:

Products Versions
TIBCO Streaming 7

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 Index
Limit: 20

How will the StreamBase CEP runtime perform this query? Specifically:
  1. Will a table scan be performed since the first part of the expression evaluates non-indexed fields?
  2. 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

  1. 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.
  2. 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)