skip to main content
OpenAccess SDK SQL engine and IP interaction : Query processing: with optimization : Steps for query processing with optimization
 

Steps for query processing with optimization

1. First, the query is received by the OpenAccess SDK SQL engine and parsed into a parse tree.
2. From the SQL statement, the type of query is determined (SELECT in this case) and the execute function that is registered by the IP to implement the query execution is called with the type of query set to SELECT. The IP is passed in column NAME as the one with search conditions.
Note: The OpenAccess SDK SQL engine knows to do this because the column NAME is marked as a primary key column and because the IP has registered that it can handle equality value sets.
3. The IP calls the optimization support function to get the value set {(=, SCOTT), (=, TOM), (=, JOE)} for the column NAME. The IP uses the NAME list to read a row matching the NAME value and evaluates against the WHERE clause by calling the evaluation function in the OpenAccess SDK SQL engine. In this example, rows with NAME values equal to SCOTT, TOM, or JOE are read and processed.
4. If the WHERE clause is true for the given row of data, then the row is added to the result set by calling a data management function in the OpenAccess SDK SQL engine.
5. Steps 3 and 4 are repeated until all rows with matching key values have been read from the database and processed.
6. The OpenAccess SDK SQL engine packages the results set and sends it to the client.
Some points to note about this approach are:
If possible, only the rows with the NAME value in the key set are read by the IP.
Execution speed of queries with key constraints depend on the number of NAME values specified and not on the size of the database.
The IP does not need to see the SQL query or the expression tree generated from the SQL statement.
The IP can make effective use of restrictions on other columns if the database access supports it (for example, FLOATVAL > 100.0).
The processing for DELETE and UPDATE is very similar to the processing described for the optimized SELECT. The processing of INSERT is a matter of reading the data sets from the OpenAccess SDK SQL engine and writing it into the data source. See Designing and coding the IP for more information.