性能分析大全
性能分析大全ASH,v$system_event , v$lock etc..
(重要)关于性能的几个主要动态视图
Troubleshooting Oracle Performance书上摘录下来,记录在这。
通过v$wait_chains视图诊断数据库hang和Contention
通过v$wait_chains视图诊断数据库hang和Contention
V$ACTIVE_SESSION_HISTORY视图的使用
转载--V$ACTIVE_SESSION_HISTORY视图的使用
时间模型V$SESS_TIME_MODEL视图
10g引用的时间模型V$SESS_TIME_MODEL视图
oracle.Performance.Tuning笔记
oracle.Performance.Tuning笔记
没有索引导致的DIRECT PATH READ
转:https://www.cnblogs.com/6yuhang/p/5923914.html 5月20号下午4-5点,某项目组进行数据入库作业,作业人员反映入库速度很慢。在16:30和16:50分别采集了快照,并根据两个快照得到AWR报告。
优化scenarios
1. 外键的列没加索引,当对主表键进行DML, 会锁住整个子表。...........................[@more@] Normal 0 false false false MicrosoftInternetExplorer4 1. 外键的列没加索引,当对主表键进行DML, 会锁住整个子表。 2. 索引失效,如where lower(name)=’ssss’, name上的索引会失效。 或者隐式的数据类型转换:where item_id=12345, 这里item_id是varchar2, 就会先隐式的转换成数字型,索引失效了。 3. PLSQL里的程序给临时表转载了很多数
外键有必要加索引
Expert Oracle Database Architecture 死锁的头号原因:不加索引的外键(第6章.锁)[@more@]http://www.cnblogs.com/angzi/archive/2006/12/09/587612.html据Tom的经验,导致死锁的头号原因是外键未加索引,第二号原因是表上的位图索引遭到并发更新。在以下两种情况下,Oracle在修改父表后会对子表加一个全表锁: ·如果更新了父表的主键(倘若遵循关系数据库的原则,即主键应当是不可变的,这种情况就很少见。)由于外键上没有索引,所以子表会被锁住。 ·如果删除了父表中的一行,整个子表也会被锁住(由于外键上没有索引,比如:如果EM
Oracle leading vs. ordered hints
http://www.dba-oracle.com/t_leading_hint.htmThe "ordered" hint is extremely useful for cutting-down query parse time and ensuring proper table join order for static tables and queries. Good article on using the ordered hint Ault on the ordered hint[@more@]/* LEA
Histograms
Histograms 就是柱状图 在你不收集Histograms信息的时候 如果存在一个表 表中的记录从1到9,一共900条记录 由于没有收集Histograms信息 oracle会假设记录是平均分配的 就是说1有100条,2有100条…… 而实际上1有800条,其他的100条 这样就会存在问题 在索引的选择上 对1的查询用全表扫描会更好 而对于其他的值用索引可能效果会更好 这时候就需要收集Histograms信息 告诉oracle数据是倾斜 不是平均分布的 v:* {behavior:url(#default#VML);} o:* {behavior:url(#default#VML);} w:* {behavior:url(#default#VML);
对Hash Join的一次优化
转: http://www.itpub.net/viewthread.php?tid=955209&extra=&page=1对Hash Join的一次优化[@more@]对Hash Join的一次优化前两天解决了一个优化SQL的case,SQL语句如下,big_table为150G大小,small_table很小,9000多条记录,不到1M大小hash_area_size, sort_area_size均设置足够大,可以进行optimal hash join和memory sortselect /*+ leading(b) use_hash(a b) */ distinct a.IDfrom BIG_TABLE a, SMALL_TABLE bwhere (a.category = b.from_cat or a.category2 = b.from_cat) and a.site_id = b.site_id and
调优: 一个SQL现在30分钟,而原来只要2秒
经过对比执行计划,是执行计划变成full table scan 和错误的表连接了,改用hint提示走索引和用正确的表连接,解决问题.但为什么在prod上是正确的计划,而在测试环境计划变了?[@more@]下面在uat上要跑30分钟, 但在prd上仅仅10秒: SELECT cd.case_id, i.item_identifier, mt.ext_trade_id, mt.mirror_id,
Oracle Hints
http://www.psoug.org/reference/hints.html[@more@]Oracle HintsVersion 10.2 Join methods:In the loop join algorithm, an outer loop is formed that is composed of a few entries that are to be selected. Then, for each entry in the outer loop, a look-up is performed for matching entries, in the inner loop.In the merge join algorithm, both tables are accessed in the same order. If there's a sorted index on the matching column, on both tables, then no sorting is needed. All we have to do is read the row
找出session正在执行什么语句
SELECT /*+ ORDERED */ sql_text FROM v$sqltext a WHERE (a.hash_value, a.address) IN ( SELECT DECODE (sql_hash_value, 0, prev_hash_value, sql_hash_value ), DECODE (sql_hash_value, 0, prev_sql_addr, sql_address) FROM v$session b WHERE b.sid = &sid)ORDER BY piece ASC/[@more@]
亿级表中创建索引
http://www.ninedns.com/oracle/200742218395312863.html, 大表建索引的一个例子.[@more@]1. 查看表的具体情况 查看是不是分区表,有多少个分区、分区字段: SQL> col table_name for a20 SQL> col column_name for a20 SQL> select a.table_name,a.partitioned,b.partition_count,c.column_name 2 from user_tables a, user_part_tables b, user_part_key_columns c 3 where a.table_name='STAT_SUBMIT_CENTER' 4 and b.table_name='STAT_SUBMIT_CENTER' 5 and c.name='STAT_SUBMIT_CENTER'; TABLE_NAME PAR PARTITION_COUNT CO
怎么估算一段时间里,几条SQL所占用的时间
http://www.itpub.net/817953.html[@more@]....................................................CPU.......ElapsdBuffer Gets Executions Gets per Exec %Total Time (s) Time (s) Hash Value--------------- ------------ -------------- ------ -------- --------- ----------57,829,948 686 84,300.2 17.0 994.30 2768.46 3580151673...17.0 == %Total994.30 =CPU Times2768.46 =Elapsed Times%CPU 在9i 的DB里只能自己估算,找到CPU used by this session 1,143,177 317.5 59.9要第一个值/100,得到Total CPU秒数然后用top sql里的cp
statspack使用手册
http://www.51tech.net/news_html/1401.htm, 包括了statspack各段的详细说明。[@more@]oracle 9i statspack使用手册 ★★★★ChinaUnix内容包括 statspack安装 statspack报告的详细说明 Statspack 使用说明 一.statspack系统安装 1 二.Statspack介绍 2 三.Statspack使用 4 四.Statspack报告说明 5 一.statspack系统安装 statspack的安装程序在@?/rdbms/admin/下: spcreate.sql 安装 spdrop.sql 卸载 spauto.sql: 生成自动采集数据任务 spreport.sql 生成分析报告 spuexp.sql 参数文件 sppurge.sql 清除不在需要的数据 sptru
执行计划中cost, card的含义
card是指计划中这一步所处理的行数。cost指cbo中这一步所耗费的资源,这个值是相对值。bytes指cbo中这一步所处理所有记录的字节数,是估算出来的一组值。 http://blog.itpub.net/post/385/45197[@more@]■ Cost The cost assigned to each step of the query plan by the CBO. The CBO works bygenerating many different execution paths/plans for the same query and assigns a cost toeach and every one. The query plan with the lowest cost wins. In the full outer join example,we can see the total cost for this query is 10
not exists的优化
3张表几乎都几千万行, 找出在ITEM表里的但没存在LINK, ITEM_LINK 里已经链接好了的ITEM_ID, 下面第一种方法是传统方法,用not exists直观, 第二种是用左外连接. 但从两种方法看效率都不高, 都要大量的连接,要nested loop. 也许修改表结构是最好的选择了,给ITEM表加个字段,如LINK_STATUS, 在ITEM_LINK,LINK已经link了,就给这个字段置位.以后再来判断就不需要用not exists来判断是否在LINK,ITEM_LINK表里已link了![@more@]SQL> SELECT I.ITEM_ID FROM ITEM I WHERE ACCOUNT_CODE = 'ICMPVMONTHEND' AND ACCOUNT_TYPE_CODE = 'TRADE' AND L