10046event 漫步
10046event 漫步: 如果你对oracle性能调优很感兴趣或者比较专长,那么你对oracle的10046事件一定不会陌生。10046event是oracle用于系统性能分析时的一个最重要的事件。当激活这个事件后,将通知oracle kernel追踪会话的相关即时信息,并写入到相应trace文件
10046event 漫步:如果你对oracle性能调优很感兴趣或者比较专长,那么你对oracle的10046事件一定不会陌生。10046event是oracle用于系统性能分析时的一个最重要的事件。当激活这个事件后,将通知oracle kernel追踪会话的相关即时信息,并写入到相应trace文件中。这些有用的信息主要包括sql是如何进行解析,绑定变量的使用情况,会话中发生的等待事件等
10046event 可分成不同的级别(level),分别追踪记录不同程度的有用信息。对于这些不同的级别,应当注意的是向下兼容的,即高一级的trace信息包含低于此级的所有信息。
10046event的追踪级别大致有:
level 1:跟踪sql语句,包括解析、执行、提取、提交和回滚等。
level 4:包括变量的详细信息
level 8:包括等待事件
level 12:包括绑定变量与等待事件
其中,level 1相当于打开了sql_trace
10046event的启用和关闭:
前提条件:(先确保要event的会话环境符合条件)
1、 必须确保timed_statistics为TRUE,这个参数可以在会话级上进行修改。
2、 为了确保trace输出能够完整进行,还要调整此会话对trace文件大小的限制,一般将此限制取消,即将max_dump_file_size设置为UNLIMITED,或者设置为一个很大的阙值。
在满足了上述条件后,就可以启用10046event对会话进行后台跟踪了。
这里还有几种方式来启用10046event:
一种是在当前会话启用event,可以利用alter session + 事件名称 + level,
如:sql>alter session set event ‘10046 trace name context forever, level 12’;
另外一种是启用别的会话进行event跟踪,可以利用oracle提供的dbms_system来完成。
如:sql>exec dbms_system.set_ev(sid,serial#,10046,12,’’);
注意:
sql>exec dbms_system.set_sql_trace_in_session(sid,serial#,true);
相当于打开了sql_trace。
event的关闭:
可以在通过下面的语句来关闭当前会话的event:
sql>alter session set event ‘10046 trace name context off’;
也可以利用dbms_system包来关闭某个会话的event:
sql>execute dbms_system.set_ev(sid,serial#,0,’’);
这里应当值得一提的是,TRACE将消耗相当的系统资源,因此我们在使用TRACE的时候应当慎重。对于正式的系统,应当只在必要的时候进行TRACE操作,并且应当及时关闭。
当利用事件trace完当前或某个session后,接下来我们的工作就是找到oracle生成的trace了。Oracle的初始化文件中user_dump_dest参数的设置将决定trace文件的生成位置。
从trace文件中查找和发现有用的信息,然后寻找必要的性能调整点并进行相应的调整:
大部分情况下,通过10046事件trace到文件里的信息包含了此会话中存在的性能问题,可以根据trace到的等待事件、SQL语句执行情况以及绑定变量的使用情况来进行分析和查找。
oracle提供了一个工具tkprof来对trace文件进行格式的翻译,以便trace文件中记录的信息能够被我们容易掌握和获取。
小知识:
检查当前会话的sql_trace状态或级别:
SQL>set serveroutput on
2 declare i_event number;
3 begin
3 sys.dbms_system.read_ev(10046,i_event);
4 dbms_output.put_line(‘the session sql_trace level is: ‘||i_event);
5 end;
6 /
the session sql_trace level is: 12
PL/SQL 过程已成功完成。

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

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











Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.
