今天是2014-01-08,继续完成等待事件系列。 什么是:db file sequential read:? 简单说,就是oracle要读取单块数据,其他会话存在等待,有三个参数p1,是要读的文件,p2是block#,开始读取的数据块号,p3是blocks,一般p3为单块,但是如果是多块那么一般发
今天是2014-01-08,继续完成等待事件系列。
什么是:db file sequential read:?
简单说,就是oracle要读取单块数据,其他会话存在等待,有三个参数p1,是要读的文件,p2是block#,开始读取的数据块号,p3是blocks,一般p3为单块,但是如果是多块那么一般发生在从temporary segment中读的。
该类等待事件的出现主要是由于执行对索引,回滚(undo)段,和表(当借助rowid来访问),控制文件和数据文件头的单块读操作SQL语句(用户和递归)引起的,该事件的产生要么表的连接顺序有问题,要么索引使用不当导致。
如何解决呢:
1、优化sql,主要是看执行计划,能不走全表的就不走全表(但是有时候全表可能比索引更快),能走index scan的就不走table access byindex rowid.
2、增加file的i/0速率,一般对于硬件存储设备而言,数据文件所在的磁盘采用哪种raid也是很显著
3、增加buffer cache大小,使其数据在内存中得到,但是到了10G、11g 启用了asmm和amm那么buffer cache是会动的,或者考虑将相关表存放到keep 池中,如果是11g可以考虑result cache。
4、可以将数据放到非标准块中(大块存多行数据),避免i/0
5、采用索引组织表,减少i/o
6、采用并行查询执行(占用一定内存和cpu,需要依据主机负载判断)
7、可以尝试采用分区表等。
案例分析:
1、获得sql信息如下:
SELECTcount(1)
FROMWF_DEAL_COMMON_MAIN_T M,
WFC_ROOT_SUB_RELATION_T R,
RT_WORKITEMINST W
WHERE M.F_PROCINST_ID = R.ROOT_ID
AND R.SUB_ID =W.PROC_INSTANCE_ID
AND W.current_statein (1,2)
AND W.USER_ID = :1
AND W.OVERDUED = :2
查看执行计划如下:
>SELECT count(1)
16:02:35 2 FROM WF_DEAL_COMMON_MAIN_T M,
16:02:35 3 WFC_ROOT_SUB_RELATION_T R,
16:02:35 4 RT_WORKITEMINST W
16:02:35 5 WHERE M.F_PROCINST_ID = R.ROOT_ID
16:02:35 6 AND R.SUB_ID = W.PROC_INSTANCE_ID
16:02:35 7 AND W.current_state in (1, 2)
16:02:36 8 AND W.USER_ID = 999
16:02:36 9 AND W.OVERDUED = 1
16:02:36 10 ;
Predicate Information (identified by operation id):
---------------------------------------------------
4 -filter(("W"."CURRENT_STATE"=1 OR"W"."CURRENT_STATE"=2) AND"W"."OVERDUED"=1 AND
TO_NUMBER("W"."USER_ID")=999)
6 -access("R"."SUB_ID"="W"."PROC_INSTANCE_ID")
filter("R"."SUB_ID"="W"."PROC_INSTANCE_ID")
8 -access("M"."F_PROCINST_ID"="R"."ROOT_ID")
Note
-----
- dynamic samplingused for this statement
index full scan,table access full。注意此时有隐式转换。
如果把变量换成字符串。执行计划如下:
>r
1 SELECT count(1)
2 FROM WF_DEAL_COMMON_MAIN_T M,
3 WFC_ROOT_SUB_RELATION_T R,
4 RT_WORKITEMINST W
5 WHERE M.F_PROCINST_ID = R.ROOT_ID
6 AND R.SUB_ID = W.PROC_INSTANCE_ID
7 AND W.current_state in (1, 2)
8 AND W.USER_ID ='999'
9* AND W.OVERDUED = 2
Predicate Information (identified by operation id):
---------------------------------------------------
4 -filter(("W"."CURRENT_STATE"=1 OR"W"."CURRENT_STATE"=2) AND"W"."OVERDUED"=2)
5 -access("W"."USER_ID"='640001312')
7 -access("R"."SUB_ID"="W"."PROC_INSTANCE_ID")
8 -access("M"."F_PROCINST_ID"="R"."ROOT_ID")
Note
-----
- dynamicsampling used for this statement
总结:
从如上内容,可以分析得出:因为w.user_id为varchar 类型,当w.user_id赋值为数字则会产生index full scan和table access full,这主要是由于隐式转换导致,解决该办法一种是建立函数索引,另一种是在传送该值变量的时候进行转换。建议采用后者。

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use

Atom editor mac version download
The most popular open source editor

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