Home Database Mysql Tutorial dbms_xplan.display_awr方式获取执行计划的实验和之前的误导

dbms_xplan.display_awr方式获取执行计划的实验和之前的误导

Jun 07, 2016 pm 04:06 PM
dbms Way Obtain

《查看Oracle执行计划的几种常用方法-系列1》(http://blog.csdn.net/bisal/article/details/38919181)这篇博文中曾提到一个隐藏问题: “ 隐藏问题2: 实验这部分内容发现使用select * from table(dbms_xplan.display_awr('sql_id'));并没有结果,@黄玮老师

《查看Oracle执行计划的几种常用方法-系列1》(http://blog.csdn.net/bisal/article/details/38919181)这篇博文中曾提到一个隐藏问题:

隐藏问题2:

实验这部分内容发现使用select * from table(dbms_xplan.display_awr('sql_id'));并没有结果,@黄玮老师说有可能是AWR收集的是top的SQL,有可能测试用的SQL不是most intensive SQL,但我是用alter system flush shared_pool后执行的手工采集快照,还是未被AWR抓到,比较奇怪的问题,这个也会在另一篇博文中仔细说明。

背景是:

“select * from table(dbms_xplan.display_awr('sql_id'));

(1)是使用explain plan for +SQL作为前提,(2)和(3)的前提则是SQL的执行计划还在共享池中,具体讲是在库缓存中。如果已经被age out交换出共享池,则不能用这两种方法了。若该SQL的执行计划被采集到AWR库中,则可以用(4)上述SQL来查询历史执行计划。”

即使用这条SQL可以查看AWR库中保存的执行计划。但我尝试用dual表做实验,发现并没有被AWR库保存他的执行计划(http://www.itpub.net/forum.php?mod=viewthread&tid=1886046&extra=)。

实验

1. 创建测试表

\

2. 查询Shared Pool中是否已经缓存了select count(*) from awr_tbl的执行计划

\

3. 喎?http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vc3Ryb25nPjxzdHJvbmc+yta5pMrVvK9BV1KxqLjmo6zH5b/VU2hhcmVkPC9zdHJvbmc+PHN0cm9uZz4gUDwvc3Ryb25nPjxzdHJvbmc+b29su7qz5bPYPC9zdHJvbmc+o7o8L3A+CjxwPjxpbWcgc3JjPQ=="http://www.2cto.com/uploadfile/Collfiles/20141029/201410290914225.png" alt="\">

看到缓冲区被清空了,刚才可以从v$sqlarea中查询的SQL信息已经删除了。

4. 使用上面提到的“select * from table(dbms_xplan.display_awr("sql_id'));”看看AWR中保存的SQL信息

\

对于@dbsnake说的dbms_xplan.display_awr("sql_id')和dbms_xplan.display_cursor的区别是不能显示谓词信息,是因为从V$SQL_PLAN导入AWR基表WRH$_SQL_PLAN时未将谓词字段access_predicates和filter_predicates导入,也做了一个实验:

\

select count(*) from sys_awr where object_name="SYS_AWR';语句,在V$SQL_PLAN中存在谓词信息:“OBJECT_NAME=”='SYS_AWR',但从WRH$_SQL_PLAN中看这两个字段是空的:\

总结

(1) select * from table(dbms_xplan.display);

(2) select * from table(dbms_xplan.display_cursor(null, null, "advanced'));

(3) select * from table(dbms_xplan.display_cursor('sql_id/hash_value', child_cursor_number, 'advanced'));

(4) select * from table(dbms_xplan.display_awr('sql_id'));

以上是使用dbms包查看执行计划的四种方法,其中:

(1)需要配合explain plan使用。

(2)、(3)需要SQL仍在Shared Pool中。

(4)需要AWR库保存该SQL信息。另外,不会显示谓词信息。

针对不同的场景选择不同的读取执行计划的方法即可。

实验过程中我曾用select * from dual作为测试SQL,但未得到如上结果,经@黄玮大师点播,认为可能是对于DUAL表的操作Oracle内部不是像正常表检索的方式来执行的,有机会可以探究。(http://www.itpub.net/forum.php?mod=viewthread&tid=1886046&extra=)

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get file extension in Python? How to get file extension in Python? Sep 08, 2023 pm 01:53 PM

A file extension in Python is a suffix appended to the end of a file name to indicate the format or type of the file. It usually consists of three or four characters, a file name followed by a period, such as ".txt" or ".py". Operating systems and programs use file extensions to determine what type of file it is and how it should be processed. Recognized as a plain text file. File extensions in Python are crucial when reading or writing files because it establishes the file format and the best way to read and write data. For example, the ".csv" file extension is the extension used when reading CSV files, and the csv module is used to process the files. Algorithm for obtaining file extension in Python. Manipulate file name string in Python.

Use math.Max ​​function to get the maximum value in a set of numbers Use math.Max ​​function to get the maximum value in a set of numbers Jul 24, 2023 pm 01:24 PM

Use the math.Max ​​function to obtain the maximum value in a set of numbers. In mathematics and programming, it is often necessary to find the maximum value in a set of numbers. In Go language, we can use the Max function in the math package to achieve this function. This article will introduce how to use the math.Max ​​function to obtain the maximum value in a set of numbers, and provide corresponding code examples. First, we need to import the math package. In the Go language, you can use the import keyword to import a package, as shown below: import"mat

Where to get Google security code Where to get Google security code Mar 30, 2024 am 11:11 AM

Google Authenticator is a tool used to protect the security of user accounts, and its key is important information used to generate dynamic verification codes. If you forget the key of Google Authenticator and can only verify it through the security code, then the editor of this website will bring you a detailed introduction on where to get the Google security code. I hope it can help you. If you want to know more Users please continue reading below! First open the phone settings and enter the settings page. Scroll down the page and find Google. Go to the Google page and click on Google Account. Enter the account page and click View under the verification code. Enter your password or use your fingerprint to verify your identity. Obtain a Google security code and use the security code to verify your Google identity.

How to get the last element of LinkedHashSet in Java? How to get the last element of LinkedHashSet in Java? Aug 27, 2023 pm 08:45 PM

Retrieving the last element from a LinkedHashSet in Java means retrieving the last element in its collection. Although Java has no built-in method to help retrieve the last item in LinkedHashSets, there are several effective techniques that provide flexibility and convenience to efficiently retrieve this last element without breaking the insertion order - a must for Java developers issues effectively addressed in its application. By effectively applying these strategies in their software projects, they can achieve the best solution for this requirement LinkedHashSetLinkedHashSet is an efficient data structure in Java that combines HashSet and

Get the latest updates now: Fix missing latest updates Get the latest updates now: Fix missing latest updates Nov 08, 2023 pm 02:25 PM

If the "Get the latest updates as soon as they become available" option is missing or grayed out, you may be running a Developer Channel Windows 11 build, and this is normal. For others, issues arise after installing the KB5026446 (22621.1778) update. Here's what you can do to get back the "Get the latest updates as soon as they become available" option. How do I get the "Get the latest updates as soon as they're available" option back? Before starting any of the solutions below, make sure to check for the latest Windows 11 updates and install them. 1. Use ViVeTool to go to the Microsoft Update Catalog page and look for the KB5026446 update. Download and reinstall the update on your PC

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

C++ program to get the imaginary part of a given complex number C++ program to get the imaginary part of a given complex number Sep 06, 2023 pm 06:05 PM

Modern science relies heavily on the concept of plural numbers, which was first established in the early 17th century by Girolamo Cardano, who introduced it in the 16th century. The formula for complex numbers is a+ib, where a holds the html code and b is a real number. A complex number is said to have two parts: the real part <a> and the imaginary part (<ib>). The value of i or iota is √-1. The plural class in C++ is a class used to represent complex numbers. The complex class in C++ can represent and control several complex number operations. Let's take a look at how to represent and control the display of plural numbers. imag() member function As mentioned above, complex numbers are composed of real part and imaginary part. To display the real part we use real()

Java program to get the size of a given file in bytes, kilobytes and megabytes Java program to get the size of a given file in bytes, kilobytes and megabytes Sep 06, 2023 am 10:13 AM

The size of a file is the amount of storage space that a specific file takes up on a specific storage device, such as a hard drive. The size of a file is measured in bytes. In this section, we will discuss how to implement a java program to get the size of a given file in bytes, kilobytes and megabytes. A byte is the smallest unit of digital information. One byte equals eight bits. One kilobyte (KB) = 1,024 bytes, one megabyte (MB) = 1,024KB, one gigabyte (GB) = 1,024MB and one terabyte (TB) = 1,024GB. The size of a file usually depends on the type of file and the amount of data it contains. Taking a text document as an example, the file size may be only a few kilobytes, while a high-resolution image or video file may be

See all articles