Viewing Query Plan

Description

To view a query plan for a CUBRID SQL query, change the value of the optimization level by using the SET OPTIMIZATION statement. You can get the current optimization level value by using the GET OPTIMIZATION statement.

The CUBRID query optimizer determines whether to perform query optimization and output the query plan by referencing the optimization level value set by the user. The query plan is displayed as standard output; the following explanations are based on the assumption that the plan is used in a terminal-based program such as the CSQL Interpreter. In the CSQL query editor, you can view execution plan by executing the ;plan command. See Session Commands. For information on how to view a query plan, see the CUBRID Manager.

Syntax

SET OPTIMIZATION LEVEL opt-level [;]
GET OPTIMIZATION LEVEL [ { TO | INTO } variable ] [;]

Example

The following example shows how to view query plan by using the example retrieving year when Sim Kwon Ho won medal and metal type.

GET OPTIMIZATION LEVEL

              Result

=============

                        1

 

SET OPTIMIZATION LEVEL 258;

 

SELECT a.name, b.host_year, b.medal

FROM athlete a, game b WHERE a.name = 'Sim Kwon Ho' AND a.code = b.athlete_code

Query plan:

  Nested loops

        Sequential scan(game b)

        Index scan(athlete a, pk_athlete_code, a.code=b.athlete_code)

There are no results.

0 rows selected.