第五部分
优化器控制
你可以用提示信息和初始化参数来影响优化器的判断和运作方式。
Influencing the Optimizer
Optimizer defaults are adequate for most operations, but not all.
In some cases you may have information unknown to the optimizer, or need to tune the optimizer for a specific type of statement or workload. In such cases, influencing the optimizer may provide better performance.
影响优化器
优化器的默认设置对大部分操作来说是够用的,但并非对所有操作都适用。
在某些情况下,你可能掌握着优化器不知道的信息,或者需要针对某类特定的语句或工作负载调整优化器。这种时候,对优化器进行干预或许能让性能变得更好。
19.1 Techniques for Influencing the Optimizer
You can influence the optimizer using several techniques, including SQL profiles, SQL Plan Management, initialization parameters, and hints.
The following figure shows the principal techniques for influencing the optimizer.
19.1 影响优化器的方法
你可以通过多种方法来影响优化器,包括 SQL 配置文件、SQL 计划管理、初始化参数以及提示信息。
下图展示了影响优化器的主要方法。
The overlapping squares in the preceding diagram show that SQL plan management uses both initialization parameters and hints. SQL profiles also technically include hints.
前面图表里那些重叠的方块说明,SQL 计划管理会同时用到初始化参数和提示信息。从技术层面来讲,SQL 配置文件里其实也包含了提示信息。
Note:
A stored outline is a legacy technique that serve a similar purpose to SQL plan baselines.
注意:
存储大纲是一种遗留技术,其作用与 SQL 计划基线类似。
You can use the following techniques to influence the optimizer:
您可以通过以下技术手段来影响优化器的行为:
In some cases, multiple techniques optimize the same behavior. For example, you can set optimizer goals using both initialization parameters and hints.
在某些情况下,多种技术手段可以优化同一类行为。例如,您既可以通过初始化参数来设置优化器目标,也可以使用提示符(Hints)来实现相同的效果。
See Also:
"Migrating Stored Outlines to SQL Plan Baselines" to learn how to migrate stored outlines to SQL plan baselines
另请参阅:
"将存储大纲迁移至SQL计划基线"了解如何将存储大纲迁移到SQL计划基线。
19.2 Influencing the Optimizer with Initialization Parameters
This chapter explains which initialization parameters affect optimization, and how to set them.
19.2 使用初始化参数影响优化器
本章将说明哪些初始化参数会影响优化过程,以及如何设置这些参数。
19.2.1 About Optimizer Initialization Parameters
Oracle Database provides initialization parameters to influence various aspects of optimizer behavior, including cursor sharing, adaptive optimization, and the optimizer mode.
The following table lists some of the most important optimizer parameters. Note that this table does not include the approximate query initialization parameters, which are described in "Approximate Query Initialization Parameters".
19.2.1 关于优化器初始化参数
Oracle数据库提供了一系列初始化参数,用于影响优化器行为的各个方面,包括游标共享、自适应优化和优化器模式。
下表列出了一些最重要的优化器参数。请注意,此表未包含近似查询初始化参数,这些参数将在"近似查询初始化参数"章节中详细说明。
See Also:
• Oracle Database Performance Tuning Guide to learn how to tune the query result cache
• Oracle Database Data Warehousing Guide to learn more about star transformations and query rewrite
• Oracle Database In-Memory Guide to learn more about Database In-Memory features
• Oracle Database Reference for complete information about the preceding initialization parameters
另请参阅:
• 《Oracle数据库性能调优指南》了解如何调优查询结果缓存
• 《Oracle数据库数据仓库指南》深入了解星型转换和查询重写
• 《Oracle数据库内存指南》了解更多数据库内存功能
• 《Oracle数据库参考》获取前述初始化参数的完整信息