Syntax Checking Phase
- Whether the all keywords present "select . . . from", etc . .
- DB semantic check against the data dictionary of the database.
- Whether the used table names spelled correctly, and present in db dictionary.
Parsing Phase
- Parse call does not return an error if the statement is not syntactically correct.
- Creation of all possible ways of query execution with different costs as per CBO and identifying and generation of query execution plan with lowest cost.
- This step uses database client/server cache, SGA, db datafiles, etc. all possible places from where data transition occurs.
- This is where the table - tablespace - datafile translation occurs.
- Once the execution plan is created, it is stored in Shared pool - library cache to facilitate re-execution. There are two types of parses:
Hard parse :
- A new SQL statement must be parsed from scratch.
- Parsing can be a very expensive operation that takes a lot of resources to execute, when there is no previously parsed version of the SQL to reuse.
- A reused SQL statement where the only unique feature are host variables.
- The best-case scenario is a parse to execute ratio of 100% which would indicates that the application if fully using bind or host variables in it.
- It’s like parses SQL once and executes many times.
Bind Phase
- In this phase, Binding lowest costs execution plan in db.
- Once the execution plan is syntactically created, Oracle gathers the parameters from the client/application for the execution. It makes the addresses of the program/host/bind variables are known to Oracle.
Execute Phase
- During the execute phase, Oracle executes the statement, reports any possible errors, and if everything normal, displays the result set. Unless the SQL statement being executed successfully, this is the last step of the query execution.
Define Phase
- The Oracle OCI interface defines addresses of the output variables known to the Oracle process in order to make it possible to the fetch call to know where to put the output variables.
Fetch Phase
- During the fetch phase, Oracle displays the resultset to the application.
Once more, the define and fetch phases are relevant for queries only.The Oracle OCI interface module contain calls to facilitate each of those phases.