Oracle 参数 OPTIMIZER_SESSION_TYPE 官方解释,作用,如何配置最优化建议

本站中文解释

OPTIMIZER_SESSION_TYPE参数用于定义当前会话中SQL优化器使用何种级别来决策会话,它是Oracle数据库从10g 开始采用的新型参数,它可以控制会话针对单独运行的SQL语句将索引,或全局索引优化,以及路由的选择。它的可设置的参数值分为:ALL_ROWS(全行优化)、FIRST_ROWS(首行优化),FIRST_ROWS_10(针对10行首行优化)三种模式。

1. ALL_ROWS模式:该模式的目的是尽可能的少的执行数据库的查询,也就是优化性能和计算资源,他最适合执行大量数据的查询工作。

2. FIRST_ROWS模式:该模式的目的是尽可能快的返回结果集,他最适合执行查询工作,只要返回部分结果集即可完成任务。

3. FIRST_ROWS_10模式:该模式与FIRST_ROWS类似,只是以更优化的方式来提高性能,他最适合执行查询工作,只要返回部分结果集前10行即可完成任务。

正确设置:根据SQL语句的需求来选择合适的优化模式。如果需要确保SQL语句的最优性能,可以使用ALL_ROWS模式;而如果需要优先考虑查询速度,可以使用FIRST_ROWS或FIRST_ROWS_10模式。

官方英文解释

OPTIMIZER_SESSION_TYPE controls how the database performs automatic indexing for SQL statements in the session.

Property Description

Parameter type

String

Syntax

OPTIMIZER_SESSION_TYPE = { NORMAL | CRITICAL | ADHOC }

Default value

NORMAL

Modifiable

ALTER SESSION

Modifiable in a PDB

No

Basic

No

Values:

  • NORMAL

    Automatic indexing is performed normally for SQL statements in the session. The automatic indexing process identifies auto index candidates, creates auto indexes, and verifies them against SQL statements.

  • CRITICAL

    Automatic indexing is performed for SQL statements in the session, with a higher priority given to long-running statements. The automatic indexing process identifies auto index candidates and creates auto indexes. However, auto indexes are verified against SQL statements in descending order of elapsed execution time for each statement.

  • ADHOC

    Automatic indexing is suspended for SQL statements in the session. The automatic indexing process does not identify auto index candidates, create auto indexes, or verify auto indexes against SQL statements. This setting is useful when running ad hoc queries or testing new functionality.

See Also:

Oracle Database
Administrator’s Guide
for more information about how automatic indexing works


数据运维技术 » Oracle 参数 OPTIMIZER_SESSION_TYPE 官方解释,作用,如何配置最优化建议