Oracle如何查看sql的真实执行计划
平常我们用explan plan for,set autotrace,utlxplan等方式查看执行计划都是optimizer模拟生成的执行计划,并不完全符合oracle内部
知识普及:
1 平常我们用explan plan for,set autotrace,utlxplan等方式查看执行计划都是optimizer模拟生成的执行计划,并不完全符合Oracle内部对sql语句的执行路径。
2 v$sqlarea中放置的父游标,放置sql的sql_id和address
3 v$sql中对应v$sqlarea中的sql的子游标,address和child_number代表唯一的子游标
查询sql在数据库中实际的sql执行计划方法:
1 set autotrace on
如果语句返回的行很多,那么结果会非常庞大,,在sqlplus里边是一个困难的选择。
set autotrace traceonly --并不能每次显示正确的执行计划,造成对sql优化的误导。
2 查询v$sql_plan是真实执行路径,但阅读比较困难。
3 使用如下语句可以查询sql的真实执行路径,并且格式化执行路径输出
set linesize 400
set pagesize 60
SELECT * FROM TABLE (SELECT DBMS_XPLAN.DISPLAY_CURSOR('a8tumy29tf0za','0') from dual);
--第一个为sql_id
--第二个为child_number

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]
