To operate efficiently, SQL Anywhere rewrites your queries into semantically equivalent, but syntactically different, forms. SQL Anywhere performs many different rewrite operations.
If you read the access plans, you frequently find that they do not correspond to a literal interpretation of your original statement. For example, to make your SQL statements more efficient, the optimizer tries as much as possible to rewrite subqueries with joins.
In the Query Rewrite phase, SQL Anywhere performs several transformations in search of more efficient and convenient representations of the query. Because the query may be rewritten into a semantically equivalent query, the plan may look quite different from a literal interpretation of your original query. Common manipulations include:
eliminating of unnecessary DISTINCT conditions
performing a predicate push-down in UNION or GROUPed views and derived tables
optimizing of OR and IN-list predicates
optimizing of LIKE predicates
converting outer joins to inner joins
eliminating of outer joins and inner joins
discovering exploitable conditions through predicate inference
eliminating of unnecessary case translation
rewriting subqueries as EXISTS predicates
Some query rewrite optimizations cannot be performed on the main query block if the cursor is updatable. Declare the cursor as read-only to take advantage of the optimizations. See Choosing cursor types, and DECLARE CURSOR statement [ESQL] [SP].
For an example of an optimization that cannot be performed if the main query block is an updatable cursor, see Elimination of unnecessary inner and outer joins.
Some of the rewrite optimizations performed during the Query Rewrite phase can be observed in the results returned by the REWRITE function. See REWRITE function [Miscellaneous].
Elimination of unnecessary DISTINCT conditions
Predicate push-down in UNION or GROUPed views and derived tables
Optimization of OR and IN-list predicates
Optimization of LIKE predicates
Conversion of outer joins to inner joins
Elimination of unnecessary inner and outer joins
Discovery of exploitable conditions through predicate inference
Elimination of unnecessary case translation
Rewriting subqueries as EXISTS predicates
Inlining user-defined functions
Inlining simple system procedures
Discuter à propos de cette page dans DocCommentXchange.
|Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0|