今天是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,这主要是由于隐式转换导致,解决该办法一种是建立函数索引,另一种是在传送该值变量的时候进行转换。建议采用后者。

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

ToaddauserremotelytoMySQL,followthesesteps:1)ConnecttoMySQLasroot,2)Createanewuserwithremoteaccess,3)Grantnecessaryprivileges,and4)Flushprivileges.BecautiousofsecurityrisksbylimitingprivilegesandaccesstospecificIPs,ensuringstrongpasswords,andmonitori

TostorestringsefficientlyinMySQL,choosetherightdatatypebasedonyourneeds:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseTEXTforlong-formtextcontent.4)UseBLOBforbinarydatalikeimages.Considerstorageov

When selecting MySQL's BLOB and TEXT data types, BLOB is suitable for storing binary data, and TEXT is suitable for storing text data. 1) BLOB is suitable for binary data such as pictures and audio, 2) TEXT is suitable for text data such as articles and comments. When choosing, data properties and performance optimization must be considered.

No,youshouldnotusetherootuserinMySQLforyourproduct.Instead,createspecificuserswithlimitedprivilegestoenhancesecurityandperformance:1)Createanewuserwithastrongpassword,2)Grantonlynecessarypermissionstothisuser,3)Regularlyreviewandupdateuserpermissions

MySQLstringdatatypesshouldbechosenbasedondatacharacteristicsandusecases:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseBINARYorVARBINARYforbinarydatalikecryptographickeys.4)UseBLOBorTEXTforlargeuns


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 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

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.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

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