SQL Engine has features that allow a DSII to alter and optimize the execution of a query according to the strengths of the data store. This takes place by providing access to the Algebraic Expression Tree (AE-Tree), which is an object-oriented representation of the operations necessary to perform the query. The ability to optimize the tree comes in two different forms:
The advantage of using Collaborative Query Execution is that it allows your DSII to take over execution of the parts of the SQL query that your data store excels at, while leaving the rest to the Simba SQLEngine. For instance, if your data store can join tables extremely quickly, then this operation can be executed by your DSII while Simba SQLEngine takes care of the rest of the operations. When Simba SQLEngine and your DSII use Collaborative Query Execution, your driver supports all of the SQL that Simba SQLEngine supports, while still exposing the strengths of your data store.
If your data store cannot perform any additional operations, then Collaborative Query Execution does not need to be used. Simba SQLEngine will still support the full range of SQL in a fast and efficient manner.
Before it executes a SQL statement, Simba SQLEngine can pass an optimized representation of the SQL statement to the DSI implementation. This optimized representation is called an Algebraic Expression Tree, or AE-Tree. The SQL statement takes this form just before Simba SQLEngine transforms it into an execution plan and executes it. When Simba SQLEngine passes the AE-Tree to the DSI implementation, the DSI implementation can choose to execute any part of the AE-Tree itself. It signals its intentions by modifying the AE-Tree before returning it to Simba SQLEngine.
For example, if your data store can filter data, or join data, or execute aggregate functions quickly, it can modify those nodes of the AE-Tree to point to the DSI implementation for execution. The DSI implementation can modify any part of the AE-Tree if it can perform the execution quickly, or it can replace the entire tree and execute the whole query itself.
The following diagram illustrates an example of creating an AE-Tree passing down a filter to the data store, then replacing the original table node with a new filtered table node:
The diagram above shows three views of a notional AE-Tree corresponding to the SQL query SELECT Col1 FROM Table1 WHERE Col2 = 23.
If pass-down succeeds, it is converted into the tree shown in the third view, where “Selection” and “=” are replaced by “Table1’”.
After the DSI implementation passes back the AE-Tree, Simba SQLEngine transforms the modified AE-Tree into an execution plan and executes it. Simba SQLEngine execution engine, and the DSI implementation and data store collaborate on the execution of the SQL statement, with the data store executing the parts it can do quickly, and Simba SQLEngine executing the rest. Of course, the DSI implementation does not have to modify the AE-Tree at all. Simba SQLEngine can execute the entire SQL statement relatively quickly and efficiently by itself.