Adaptive Server performs the following steps to process ad hoc SQL statements using the statement cache:
Adaptive Server parses the statement.
If the statement should be cached (see “Caching conditions”), Adaptive Server computes a hash value from the statement. Adaptive Server uses this hash value to search for a matching statement in the statement cache (see “Statement matching criteria”).
If a match is found in the statement cache, Adaptive Server skips to step 4.
If a match is not found, Adaptive Server proceeds to step 2.
Adaptive Server caches the SQL statement text.
Adaptive Server wraps the SQL statement with a lightweight stored procedure and changes any local variables into procedure parameters. The internal representation of the lightweight procedure is not yet compiled into the plan.
Adaptive Server converts the SQL statement into an execute statement for the corresponding lightweight procedure.
If there is no plan in the cache, Adaptive Server compiles the procedure and caches the plan. Adaptive Server compiles the plan using the assigned runtime values for the local variables.
If the plan exists but is invalid, Adaptive Server returns to step 3 using the text of the cached SQL statement.
Adaptive Server then executes the procedure.
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |