第五部分
優化器控制
你可以用提示信息和初始化參數來影響優化器的判斷和運作方式。
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數據庫參考》獲取前述初始化參數的完整信息