当前位置: 首页 > news >正文

Oracle sql tuning guide 翻译 Part 6-5 --- Hint使用报告的操作优秀的方法和例子

19.3.3.3 Reporting on Hint Usage: Tutorial

You can use the DBMS_XPLAN display functions to report on hint usage.

19.3.3.3 提示符使用报告:操作教程

可以使用DBMS_XPLAN显示函数来生成提示符使用报告。

Hint usage reporting is enabled by default. The steps for displaying a plan with hint information are the same as for displaying a plan normally.

提示符启用报告功能默认处于启用状态。显示包含提示符信息的执行计划步骤与常规执行计划显示步骤完全一致。

Assumptions

This tutorial assumes the following:

前提条件
本操作教程基于以下假设:

• An index named emp_emp_id_pk exists on the employees.employee_id column.

• You want to query a specific employee.

• You want to use the INDEX hint to force the optimizer to use emp_emp_id_pk.

•在employees.employee_id列上存在名为emp_emp_id_pk的索引
•需要查询特定员工信息
•计划启用INDEX提示符强制优化器使用emp_emp_id_pk索引

To report on hint usage:

1. Start SQL*Plus or SQL Developer, and log in to the database as user hr.

2. Explain the plan for the query of employees. For example, enter the following statement:

生成提示符使用报告的步骤:

1. 启动SQL*Plus或SQL Developer,以hr用户身份登录数据库

2. 解析employees表查询的执行计划
例如,输入以下语句:

3. Query the plan table using a display function.

You can specify any of the following values in the format parameter:

3. 使用显示函数查询计划表
可以在format参数中指定以下任意值:

• ALL

• TYPICAL

The following query displays all sections of the plan, including the hint usage information (sample output included):

以下查询将显示执行计划的所有部分,包括提示符使用信息(包含示例输出):

The Hint Report section shows that the query block for the INDEX(e emp_emp_id_pk) hint is SEL$1. The table identifier is E@SEL$1. The line number of the plan line is 2, which corresponds to the first line where the table E@SEL$1 appears in the plan table.

提示符报告部分显示,INDEX(e emp_emp_id_pk)提示符对应的查询块为SEL$1。表标识符为E@SEL$1。计划行号显示为2,对应计划表中E@SEL$1表首次出现的行位置。

See Also:

Oracle Database SQL Language Reference to learn more about EXPLAIN PLAN

另请参阅
Oracle Database SQL Language Reference 了解有关EXPLAIN PLAN的更多信息

19.3.3.4 Hint Usage Reports: Examples

These examples show various types of hint usage reports.

The following examples all show queries of tables in the hr schema.

19.3.3.4 提示符启用报告:示例

以下示例展示各类提示符使用报告的具体形式。

所有示例均展示对hr模式中表的查询操作。

Example 19-2 Statement-Level Unused Hint

The following example specifies an index range hint for the emp_manager_ix index:

示例19-2语句级未使用提示符
以下示例为emp_manager_ix索引指定了索引范围提示符:

The following query of the plan table specifies the format value of TYPICAL, which shows only unused hints:

以下对计划表的查询指定了TYPICAL格式值,该设置仅显示未使用的提示符:

The U in the preceding hint usage report indicates that the INDEX_RS hint was not used. The report shows the total number of unused hints: U – Unused (1).

前述提示符使用报告中的"U"标记表明INDEX_RS提示符未被使用。报告同时显示未使用提示符的总数统计:U - 未利用(1个)。

Example 19-3 Conflicting Hints

The following example specifies two hints, one for a skip scan and one for a fast full scan:

示例19-3冲突的提示符
以下示例指定了两个相互冲突的提示符:一个要求跳跃扫描,另一个要求快速全扫描:

The following query of the plan table specifies the format value of TYPICAL, which shows only unused hints:

以下对计划表的查询指定了TYPICAL格式值,该设置仅显示未使用的提示符:

The preceding report shows that the INDEX_FFS(e) and INDEX_SS(e emp_manager_ix) hints conflict with one other. Index skip scans and index fast full scans are mutually exclusive. The optimizer ignored both hints, as indicated by the text U — Unused (2). Even though the optimizer ignored the hint specifying the emp_manager_ix index, the optimizer used this index anyway based on its cost-based analysis.

前述报告显示INDEX_FFS(e)和INDEX_SS(e emp_manager_ix)两个提示符相互冲突。索引跳跃扫描与索引快速全扫描是互斥操控。优化器同时忽略了这两个提示符,如报告中的"U — 未使用(2个)"所示。尽管优化器忽略了指定emp_manager_ix索引的提示符,但基于成本分析优化器最终仍选择了该索引。

Example 19-4

Multitable Hints The following example specifies four hints, one of which specifies two tables:

示例19-4多表提示符
以下示例指定了四个提示符,其中一个提示符涉及对两个表的操作:

The preceding report shows that two hints were not used: USE_NL(t1, t2) and NLJ_PREFETCH(t2). Step 3 of the plan is an index full scan of the jobs table, which uses the alias t1. The report shows that the optimizer did not apply the USE_NL(t1, t2) hint for the access of jobs. Step 4 is an index unique scan of the employees table, which uses the alias t2. No U prefix exists for USE_NL(t1, t2), which means that the optimizer did use the hint for employees.

前述报告显示有两个提示符未被使用:USE_NL(t1, t2)和NLJ_PREFETCH(t2)。执行计划第3步是对jobs表(使用别名t1)的索引全扫描。报告表明优化器在处理jobs表时未应用USE_NL(t1, t2)提示符。第4步是对employees表(使用别名t2)的索引唯一扫描。USE_NL(t1, t2)提示符前没有U标记,说明优化器在处理employees表时实际采用了该提示符。

http://www.jsqmd.com/news/130286/

相关文章:

  • 基于 Python 的人脸+服装双重验证照片识别系统
  • 什么是 ‘Linker Scripts’ (链接脚本)?控制 C++ 段(.text, .data, .bss)在物理内存中的布局
  • 有什么好用的降AIGC疑似度工具,知网AI率90%!
  • SPSS——“Kaplan-Meier生存分析”
  • 手持雷达流速仪在应急场景监测中的应用与实践
  • Pydantic-DeepAgents:基于 Pydantic-AI 的轻量级生产级 Agent 框架
  • CLRNet车道线检测模型在Orin Nano Super开发板上的全栈部署与优化实践
  • 解析 ‘Bootloader’ 中的 C++ 环境初始化:从全局变量构造到堆栈指针设置全过程
  • 智能逗狗神器方案开发,狗狗跳跳球MCU方案设计
  • 降低知网AIGC疑似度最有效方法!AI率从100%到5%!
  • 如何利用 C++ 实现自定义的 `operator new`:为特定组件构建高性能的片上内存分配器
  • 2025国内最新中央空调服务商top10测评!山东临沂等地区优质品牌权威榜单发布,绿色能源赋能多领域温控生态 - 全局中转站
  • 零模就这样吧
  • 40、SharePoint 2010及相关工具安装与站点集创建指南
  • 2025激光切割机厂家,专业国内激光切割机厂家综合榜单 - 栗子测评
  • 2025激光切割机厂家,专业国内激光切割机厂家综合榜单 - 栗子测评
  • step-audio-2 接入实战指南:从入门到生产部署
  • 基于MATLAB的模糊逻辑算法控制给定交叉口红绿灯系统
  • 2025/12/23 今天学的day9的lecode的344和151
  • 20251223给飞凌OK3588-C开发板适配Rockchip原厂的Buildroot【linux-6.1】系统时解决给TF卡写入大文件破坏文件系统的问题
  • 向海康 ISC学习
  • 41、SharePoint开发准备与开发者仪表盘使用指南
  • 别再乱改了!这样降低知网AIGC疑似度,语言自然、逻辑严密
  • step-audio-2 企业级接入全攻略:从配置到运维
  • 基于MPC的换道五次多项式换道:Simulink与CarSim联合仿真之旅
  • 平衡树 学习笔记 - -Graphic
  • 推行无纸化审图,国产CAD助力企业降本增效与绿色办公
  • 强强联合赋能文化艺人培育 艾进工作室与乐华娱乐战略签约启新篇
  • java多线程
  • 打造团队专属的测试效能平台:2025年低代码/零代码在测试工具中的应用