Skip to content

How is a query executed in Altibase?#

Overview#

This article describes the steps Altibase takes from receiving a DML statement (SELECT, INSERT, UPDATE, DELETE, etc.) to executing it.

Version#

All versions of Altibase

Query Execution Process#

Altibase executes a query in the following five steps.

flowchart LR
    A[SQL statement] --> B[Parsing] --> C[Validation] --> D[Optimization] --> E[Binding] --> F[Execution]
Step Module What it does Output
Parsing Parser Checks the syntax of the SQL statement. Parse Tree
Validation Validator Checks the semantic validity of the SQL statement (object existence, data types, privileges). Checked Parse Tree
Optimization Optimizer Finds the most efficient way to execute the statement. Plan Tree
Binding Query processor Binds host variable values to the execution plan. Execution plan with bound values
Execution Executor Executes the SQL statement according to the Plan Tree. Execution result

Parsing#

The parser checks the syntax of the SQL statement. If there are no syntax errors, it generates a Parse Tree for the validation step.

Because this step checks only the syntax, it does not query the system tables or access the database.

Validation#

The validator queries the system tables to resolve the database objects referenced by the SQL statement (tables, columns, views, synonyms, stored procedures, and so on), and checks that the objects exist, that the data types are correct, and that the user has the required privileges. View expansion and synonym resolution are also performed in this step.

Optimization#

The optimizer calculates statistics and access costs to find the most efficient way to execute the Checked Parse Tree, and generates a Plan Tree.

For more information on optimization, see the Performance Tuning Guide in the Performance Tuning Guide.

Binding#

For an SQL statement that contains host variables (?), the host variable values are bound to the generated execution plan. The execution plan can be created once and then executed many times with only the values changed.

Execution#

The executor executes the SQL statement according to the Plan Tree generated by the optimizer.