SQL优化-关于ORDERED-HASH中错误选择连接字段对性能的影响
关于ORDERED-HASH中错误选择连接字段对性能的影响[@more@]在BOSS项目的优化过程中,遇到了这么一个情况:SELECT">heyf@VOUCHER>SELECT /*+ ordered use_hash(c t cr con ) */ count( distinct c.customer_id) FROM crm_customer c, (select t.customer_id,max(t.gmt_train) gmt_train from crm_train_record t where t.gmt_train >= to_date('2008-02-01', 'yyyy-MM-dd') - 5 and t.gmt_train < to_date('2009-02-26','yyyy-MM-dd')+
SQL优化-COUNT_ INDEX的巧用
一个SQL COUNT 优化案例,作一个小结[@more@]SQL需求:在一个8000W的表中,找出修改时间为某一时间段的记录,并且某字段不为空:select count(*) from aliim.udb_user_profile a where a.gmt_modified >= to_date('2008-07-21 14:29:38', 'yyyy-mm-dd hh24:mi:ss') and a.gmt_modified <= to_date('2008-07-21 15:34:50', 'yyyy-mm-dd hh24:mi:ss') and a.AEP_USER_ID is not null首先想到的是在 gmt_modified 字段中创建单列索引,让查询走索引,并返回到表中过滤 a.AEP_USER_ID is not null.create index udb_user_profile_g
行的存储(块内连接与块外连接)
都说ORACLE一个行能存储1000个字段,本人在看CONCEPTS的时候发现这么一段:Oracle stores each row of a database table containing data for less than 256 columns as one or more row pieces.咋一眼看上去,以为CONCEPTS说只能存储256个字段。 再仔细看:[@more@]If an entire row can be inserted into a single data block,then Oracle stores the row as one row piece. However, if all of a row’s data cannot be inserted into a single data block or an update to an existing row causes the rowto outgrow its data block,
关于锁的快速定位
当我们在执行某个update,或delete的时候,发布自己的SQL等在那里,如何更快速地定位到问题源?[@more@]--------查看哪些对象被锁了!select t2.username, t2.sid, t2.serial#, t3.object_name, t2.OSUSER, t2.MACHINE, t2.PROGRAM from v$locked_object t1, v$session t2, dba_objects t3 where t1.session_id = t2.sid and t1.object_id = t3.object_id order by t2.logon_time;--------察看表锁(可以查看什么类型的锁)select /*+ rule */ s.sid sid,s.username username,s.machine machine,l.
SQL优化好助手:Runstats
在SQL优化的过程中,我们有时候需要比较两个SQL或者过程的性能.这里推荐一个工具:RUNSTATS包[@more@]这个包在使用前需要自己创建,脚本如下: conn / as sysdba; grant select on V_$STATNAME to &&USERNAME; grant select on V_$MYSTAT to &USERNAME; grant select on V_$TIMER to &USERNAME; grant select on V_$LATCH to &USERNAME; drop table run_stats; create global temporary table run_stats ( runid varchar2(15), name varchar2(80), value int ) on commit preserve rows;--create VIEWcr
执行计划大刚OUTLINE的管理
10G,LINUX as3[@more@]更改优化器 alter session set optimizer_boal=choose;--first_rows创建OUTLINE,看执行计划,如果计划合适,就为SQL创建OUTLINE create or replace outline myoutline for category mycategory on select empno ,ename from emp where empno>0; 或者 alter session set create_stored_outlines=true; alter session set create_stored_outlines=false; -----注意,以上两种方式产生的OUTLINE有区别: 用例子来说明。 <见CURSOR_CHARING=FORCE与大刚>让SESSION使用O
Ora10G 用ASH生成性能报告
报告内容:TOP等待事件,TOP SQL,TOP SQL命令类型,TOP Session内容.[@more@]具体实现方式: SQL> @$ORACLE_HOME/rdbms/admin/ashrpt.sqlCurrent Instance~~~~~~~~~~~~~~~~DB Id DB Name Inst Num Instance----------- ------------ -------- ------------631770879 ORA10 1 ora10Specify the Report Type~~~~~~~~~~~~~~~~~~~~~~~Enter 'html' for an HTML report, or 'text' for plain textDefaults to 'html'Enter value for report_type: text --输入产生的报告文件类型Type Specified: textInstances in this Workload Repository sche
关于行链接和行迁移和消除
关于行链接和行迁移和几种消除方法(看书笔录)[@more@]Oracle中行迁移和行链接的清除及检测一、行迁移和行链接的介绍 在实际的工作中我们经常会碰到一些Oracle数据库性能较低的问题,当然,引起Oracle数据库性能较低的原因是多方面的,我们能够通过一些正确的设计和诊断来尽量的避免一些Oracle数据库性能不好,Row Migration (行迁移) & Row Chaining (行链接)就是其中我们可以尽量避免的引起Oracle数据库性能低下的潜在问题。通过合理的诊断行迁移和行链接,我们可以较大幅度上提高Oracle数据库的性能。 那究竟什么是行迁移和行链接呢
如果降低表的HWM
看书笔记[@more@](HWM=total_blocks-Unused Blocks+1)可以在DUMP文件第一个EXTENT的前三个数据块中看到HWM.释放在HWM之上的空闲BLOCK:alter table table_name deallocate usused;在HWM之下的空闲块:1. 了解一个table在HWM下有多少blocks是不包含数据的.analyze table &t_name compute statistics;select (1-a.num/b.num_total)*100 as percent from (select count(distinct substr(rowid,1,15)) num from &t_name ) a,(select blocks-empty_blocks num_total from user_tables where table_name='&t_name' )b 在ASSM下,free s
oracle常见等待事件及处理方法
看书笔记db file scattered read DB ,db file sequential read DB,free buffer waits,log buffer space,log file switch,log file sync[@more@] 我们可以通过视图v$session_wait来查看系统当前的等待事件,以及与等待事件相对应的资源的相关信息,从而可确定出产生瓶颈的类型及其对象。v$session_wait的p1、p2、p3告诉我们等待事件的具体含义,根据事件不同其内容也不相同,下面就一些常见的等待事件如何处理以及如何定位热点对象和阻塞会话作一些介绍。 <1> db file scattered read DB 文件分散读取 (太多索引读,全表扫描-----调
Oracle9i的动态SGA,PGA特性探索
参考:http://www.linuxmine.com/77890.html[@more@]http://www.dba-oracle.com/oracle_news/2005_12_19_10g_release_changes.htm“In the latest release 10.2 Oracle changed these default values. The memory allocated to a single SQL operator (_smm_max_size) is limited to:for P_A_T <= 500MB the parameter _smm_max_size = 20% of P_A_Tfor P_A_T between 500MB and 1000MB the parameter _smm_max_size = 100Mfor P_A_T betweeen 1001MB and 2560MB (2.5GB) the parameter _smm_max_size = 10% of P_A_TI have seen even c
对锁的理解(转载)
关于锁的几种类型和相关参数[@more@] 设立封锁机制主要是为了对并发操作进行控制,对干扰进行封锁,保证数据的一致性和准确性。Oracle数据库封锁方式有三种:共享封锁,独占封锁,共享更新封锁 封锁类型 Oracle RDBMS的封锁类型可分为如下三类: 1、内部级封锁 内部级封锁是用于保护ORACLE内部结构,由系统内部实现,用户不能访问。 2、DDL级封锁(字典/语法分析封锁) DDL级封锁也是由ORACLE RDBMS来控制,它用于保护数据字典和数据定义改变时的一致性和完整性。它是系统在对SQL定义语句作语法分析时自动地加锁,无需