沈阳网站备案,住房和城乡建设部网站防烟排烟,做网站后台需要什么,想自己做个网站怎么做一般来说,数据库处理SQL都会经过三个过程:解析(parse)、执行(exec)、返回结果(fetch)1.解析当用户发起一个SQL语句时#xff0c;Oracle通过Server Process 接收SQL语句到达oracle实例#xff0c;并在Shared pool 中的 Library Cache 查找是否存在该语句对应执行计划的缓存。如…一般来说,数据库处理SQL都会经过三个过程:解析(parse)、执行(exec)、返回结果(fetch)1.解析当用户发起一个SQL语句时Oracle通过Server Process 接收SQL语句到达oracle实例并在Shared pool 中的 Library Cache 查找是否存在该语句对应执行计划的缓存。如果不存在则将该SQL进行硬解析(Hard parse)生成最优化的执行计划(plan)并将该执行计划等信息载入Library Cache。如果存在则不经过硬解析而是直接进行软解析(Soft parse)从而减少数据库的分析时间。2.执行server process首先在buffer cache中查找是否存在该执行计划所对应的数据块如果存在就直接进行DML操作(逻辑IO)否则应从数据文件中将数据块读取到buffer cache中再进行DML操作(物理IO)。3.返回结果对于SELECT语句需要返回结果首先看是否需要排序如果需要则排序后返回给用户。对于其他DML语句(insert/delete/update)则无需返回结果。当buffer cache中的数据块被修改时server process将自动记录buffer的改变过程到SGA中的redo log buffer最终分别由DBWR和LGWR进程负责将buffer cache中的脏数据块和redo log buffer中的日志写到磁盘中的data file和redo log file。解析类型硬解析、软解析、软软解析对SQL的解析都需要频繁地访问数据字典硬解析判断SQL语句是否存在语法、语义的问题判断SQL语句所涉及的对象(表、视图)是否存在判断执行SQL语句的用户对涉及的对象是否有权限选择最优的执行方案,生成执行计划其中生成执行计划最消耗系统资源(CPU、I/O、Memory)尤其是CPU和I/O资源软解析只判断SQL语句的语法、语义、对象权限而不生成执行计划软软解析不解析SQL select name,value from v$sysstat where name like parse% ;NAME VALUE------------------------------ ----------parse time cpu 1339parse time elapsed 17374parse count (total) 23639parse count (hard) 3060parse count (failures) 149parse count (describe) 9命中率命中率在Oracle数据库的多个地方都会被提起例如当一个进程需要访问数据时首先确定数据是否存在Buffer Cache中如果存在(称为高速缓存命中)则直接读取数据(逻辑IO/内存读)如果不存在(称为高速缓存未命中)则需要在Buffer Cache中寻找足够的空间将磁盘上需要的数据块复制到Buffer Cache中(物理IO/硬盘读)。命中率逻辑IO/(逻辑IO物理IO)*100%注如果命中率低肯定有问题但命中率高不一定没问题(逻辑IO远高于物理IO但物理IO仍旧很高的情况下)可以通过操作系统命令vmstat、iostat查看当前系统的IO情况[oracleora11g ~]$ vmstat 1 5procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------r b swpd free buff cache si so bi bo in cs us sy id wa st1 0 0 374572 25260 788168 0 0 262 34 239 253 1 4 80 16 02 0 0 374556 25268 788172 0 0 0 36 909 1341 0 1 99 0 00 0 0 374556 25268 788172 0 0 0 0 876 1248 0 1 99 0 00 0 0 374556 25268 788172 0 0 16 80 974 1495 0 1 99 0 00 0 0 374556 25276 788164 0 0 0 48 966 1428 0 1 99 0 0[oracleora11g ~]$ iostat 1 5Linux 2.6.18-308.el5 (ora11g.example.com) 07/17/2013avg-cpu: %user %nice %system %iowait %steal %idle1.00 0.00 3.85 15.19 0.00 79.96Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtnsda 33.72 1551.26 202.49 1052263 137352sda1 0.10 2.58 0.01 1749 4sda2 22.27 1256.66 141.92 852432 96271sda3 0.07 2.37 0.00 1610 0sda4 0.01 0.02 0.00 11 0sda5 2.17 58.06 4.54 39382 3080sda6 2.40 60.32 15.53 40920 10532sda7 2.85 77.55 16.47 52605 11173sda8 3.01 76.16 8.77 51663 5949sda9 0.80 17.03 15.25 11554 10343avg-cpu: %user %nice %system %iowait %steal %idle0.00 0.00 0.55 0.00 0.00 99.45Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtnsda 5.00 32.00 128.00 32 128sda1 0.00 0.00 0.00 0 0sda2 0.00 0.00 0.00 0 0sda3 0.00 0.00 0.00 0 0sda4 0.00 0.00 0.00 0 0sda5 0.00 0.00 0.00 0 0sda6 1.00 0.00 32.00 0 32sda7 2.00 32.00 32.00 32 32sda8 1.00 0.00 32.00 0 32sda9 1.00 0.00 32.00 0 32avg-cpu: %user %nice %system %iowait %steal %idle0.26 0.00 0.77 0.26 0.00 98.71Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtnsda 2.00 0.00 104.00 0 104sda1 0.00 0.00 0.00 0 0sda2 2.00 0.00 104.00 0 104sda3 0.00 0.00 0.00 0 0sda4 0.00 0.00 0.00 0 0sda5 0.00 0.00 0.00 0 0sda6 0.00 0.00 0.00 0 0sda7 0.00 0.00 0.00 0 0sda8 0.00 0.00 0.00 0 0sda9 0.00 0.00 0.00 0 0avg-cpu: %user %nice %system %iowait %steal %idle0.26 0.00 0.26 0.00 0.00 99.48Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtnsda 4.00 0.00 32.00 0 32sda1 0.00 0.00 0.00 0 0sda2 0.00 0.00 0.00 0 0sda3 0.00 0.00 0.00 0 0sda4 0.00 0.00 0.00 0 0sda5 1.00 0.00 8.00 0 8sda6 1.00 0.00 8.00 0 8sda7 1.00 0.00 8.00 0 8sda8 0.00 0.00 0.00 0 0sda9 1.00 0.00 8.00 0 8avg-cpu: %user %nice %system %iowait %steal %idle0.00 0.00 0.78 0.00 0.00 99.22Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtnsda 13.00 160.00 208.00 160 208sda1 0.00 0.00 0.00 0 0sda2 4.00 0.00 80.00 0 80sda3 0.00 0.00 0.00 0 0sda4 0.00 0.00 0.00 0 0sda5 0.00 0.00 0.00 0 0sda6 1.00 0.00 32.00 0 32sda7 3.00 64.00 32.00 64 32sda8 4.00 96.00 32.00 96 32sda9 1.00 0.00 32.00 0 32也可以通过v$buffer_pool_statistics视图查看命中率的情况SQL SELECT NAME, PHYSICAL_READS, DB_BLOCK_GETS, CONSISTENT_GETS,(1-(PHYSICAL_READS/(DB_BLOCK_GETSCONSISTENT_GETS)))*100 Hit Ratio FROM V$BUFFER_POOL_STATISTICS WHERE NAMEDEFAULT;NAME PHYSICAL_READS DB_BLOCK_GETS CONSISTENT_GETS Hit Ratio-------------------- -------------- ------------- --------------- ----------DEFAULT 12786 14986 158305 92.6216595