Process documentationSQL Optimizer Procedure Locate this document in the navigation structure

 

SQL statements merely specify the results that are desired. They do not contain any information as to how the database system should search for the data. The database system can often choose from multiple options for finding the data required by the SQL statement.

The SQL Optimizer has the task of determining the best search strategy for accessing the data.

Process

  1. A database user or a database application sends an SQL statement with a search condition to the database.

    Example Example

    SELECT * FROM hotel.customer

      WHERE name BETWEEN 'B' AND 'P' AND firstname = 'Greg'

    End of the example.

    See Search conditions

  2. The database system transforms the SQL statement to the most suitable form.

  3. The database system starts the SQL Optimizer.

  4. The SQL Optimizer determines all the search strategies with which the database can access the data specified in the SQL statement.

    See Search strategies

  5. The SQL Optimizer determines the costs for every one of these search strategies. For this the SQL Optimizer uses statistics on the database tables.

    See Cost Determination, SQL Optimizer Statistics

  6. The SQL Optimizer chooses the search strategy that incurs the lowest costs when executing the SQL statement.

  7. The database system executes the SQL statement with this search strategy.

More Information

SQL Optimizer