skip to main content
Corticon Studio: Rule Modeling Guide : Writing Rules to access external data : Precondition and Filters as query filters : Filter Queries: Single Alias
 

Try Corticon Now
Filter Queries: Single Alias
Studio determines where Preconditions/Filters apply (either as a Query Filter in the database during retrieval or as a standard filter in working memory after database retrieval) based on their execution sequence. Only one expression per alias can be executed as a Query Filter, so if more than one expression uses an extended-to-database alias, then only the expression processed first is applied inside the database; the rest are processed in memory. Note that even a child-level alias (in other words, a non-root-level entity) whose root is extended to the database is also, by association, extended to the database for the purpose of query processing, as shown:
Figure 211. Extend to Database Aliases with Multiple Aliases Referenced as Preconditions
That figure shows alias a extended to the database. Since alias b is based on alias a (it’s a “child” of entity A), it is also considered to be extended to the database for query processing purposes. Therefore, the first Filter processed referring to alias e and/or alias b is a Query Filter provided the expression “qualifies” as a Filter Query (see above). These qualification criteria are described further below. Clearly, only one expression refers to alias a and that is Precondition/Filter row 2. This expression is processed as a Query Filter. However, there are two expressions referring to alias b. To determine which acts as a Filter Query, we need to determine which is processed first.
To determine which expression gets processed first, generate an execution sequence diagram by choosing Rulesheet>Rulesheet>Execution Sequence Diagram from Studio’s menubar. The execution sequence diagram representing the Rulesheet above is as shown below:
Figure 212. The Rulesheet’s Execution Sequence Diagram
As you can see, Precondition/Filter row 2 (F.2) is processed prior to Precondition/Filter row 3 (F.3). Since both Precondition/Filters refer to alias b, Precondition/Filter row 2 is used in the Query Filter and Precondition/Filter row 3 is processed in memory after the query results are retrieved and added to working memory.
Notice the double border around F.1 and F.2 above – this symbology denotes Query Filter.
Careful readers will also recall the second qualifying condition for Query Filters: no Booleans. So F.3 never had a chance of being a Query Filter, regardless of execution sequence!