Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - SQL Usage » Queries and data modification » Queries » Advanced: Query optimization


Optimizations performed during query processing

In the Query Rewrite phase, SQL Anywhere performs semantic 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 your original query. Common manipulations include:

  • Eliminating unnecessary DISTINCT conditions

  • Un-nesting subqueries

  • 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 outer joins and inner joins

  • Discovering exploitable conditions through predicate inference

  • Eliminating unnecessary case translation

  • Rewriting subqueries as EXISTS predicates

  • Inferring sargable IN predicates, which can be used for partial index scans from OR predicates that cannot be transformed into AND 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.

Some of the rewrite optimizations performed during the Query Rewrite phase can be observed in the results returned by the REWRITE function.

 See also