《查看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=)

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi


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

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

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

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

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

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
