Oracle IMP
通过参数文件,使用一些好用的选项 imp parfile=.par.txtpar.txt中好用的选项举例userid=xxx/xxx@xxxfile=.xxx.dmplog=.xxx.logfromuser=(xxx)touser=(xxx)feedback=20000commit=ybuffer=134217728indexes=nanalyze=ngrants=nindexes=n表示除了必要的如pk之外的索引,其他索引不导入[@more@]
Cursor Sharing监控相关语句
自己总结和摘录的一些如何发现cursor sharing问题相关的一些SQL,很多是摘自Performance Tuning Guide,绝大部分并非原创。主要是探讨如何去发现相似的SQL或者查找SQL没有共享的原因。[@more@]-- 如果不知道那个进程或者程序有问题可以在v$sesstat中查看parse count和execute count的比例,比例高说明存在cursor sharing方面的问题SELECT pa.SID, pa.VALUE "Hard Parses", ex.VALUE "Execute Count"FROM V$SESSTAT pa, V$SESSTAT exWHERE pa.SID = ex.SIDAND pa.STATISTIC#=(SELECT STATISTIC#FROM V$STATNAME WHERE
查看系统中各种等待时间占用的数据库时间比例
-- 摘自Performance Tuning Guide SELECT EVENT, WAIT_CLASS,TIME_WAITED_MICRO,ROUND(TIME_WAITED_MICRO*100/S.DBTIME,1) PCT_DB_TIMEFROM V$SYSTEM_EVENT E, V$EVENT_NAME N,(SELECT VALUE DBTIME FROM V$SYS_TIME_MODEL WHERE STAT_NAME = 'DB time') SWHERE E.EVENT_ID = N.EVENT_IDAND N.WAIT_CLASS NOT IN ('Idle', 'System I/O')ORDER BY PCT_DB_TIME ASC;[@more@]
一个经常存取的表,一定要把它的数据和索引分布在不同的磁盘上吗?
One popular approach to manual I/O distribution suggests separating a frequently used table from its index. This is not correct. During the course of a transaction, the index is read first, and then the table is read. Because these I/Os occur sequentially, the table and index can be stored on the same disk without contention. It is not sufficient to separate a datafile simply because the datafile contains indexes or table data. The decision to segregate a file should be made only when the I/O ra
ORA-12518错误
在做压力测试的时候,出现这个错误,搞了好久,网上也找不到什么好的方法,后来看到这个错误之前有个out of process memory错误,所以,估计是32位系统的内存限制问题,把SGA_TARGET从1.5G改成1G,就没有出现这个问题。基本的经验就是在32位的4G内存的机器上,PGA_AGGREGATE_TARGET + SGA_TARGET不能够超过2G,否则可以支持的连接数就变少。(难道创建连接需要用到额外的系统内存空间?)[@more@]
常用的Oracle脚本参考
http://www.oracle-base.com/dba/DBACategories.php2008-05-21:基本上都是一些简单的东西,注释也不错,比较容易看懂,在这个基础上自行总结汇总还是需要的。[@more@]
查看客户端对PGA使用的高水位值(PGA_MAX_MEM超过10M一般都有优化空间)
select s.username, s.machine, trunc(p.pga_used_mem/(1024*1024)) used_memory, trunc(pga_alloc_mem/(1024*1024)) allocated_memory, trunc(pga_max_mem/(1024*1024)) max_memory from v$process p, v$session swhere p.addr = s.paddrorder by pga_max_mem desc;[@more@]
数据库统计信息不更新导致的性能问题
SQL如下,系统动态生成的,主要是查看符合多个条件付款对应的所有明细记录。语句本身有问题,因为,多个in可以合并成一个in,相关的条件and起来即可,这个暂时忽略。SELECT doc.* FROM TLK_PAYMENT_DETAIL doc WHERE ISTMP=0 AND (((((((ITEM_contractnumber = '06603833')) AND (doc.parent in (select parentdoc.id from TLK_TEPAYMENT_MAIN parentdoc where parentdoc.ITEM_单据类型 IN ('4','8')))) AND (doc.parent in (select parentdoc.id from TLK_TEPAYMENT_MAIN parentdoc where parentdoc.ITEM_IsReverse = '0'))) AND (doc.pa
删除数据库表空间
几个必要的步骤:1 - alter tablespace xxxx offline normal;2 - drop tablespace xxxx including contents and datafiles3 - 由于windows版本的oracle不会自动删除文件,需要重启oracle,删除文件。[@more@]
通过表空间切换,回收undo表空间
在网上搜索的信息基础上加工而来,非原创。[@more@]UNDO表空间越来越大,产生问题的原因主要以下两点:1. 有较大的事务量曾经让Oracle Undo自动扩展2. 有较大事务长时间没有提交曾经让Oracle Undo自动扩展UNDO表空间变大后,把空间回收比较麻烦,Shrink命令经常不成功,但是可以通过切换UNDO表空间的方法,回收磁盘空间解决步骤:1. 启动SQLPLUS,并用sys登陆到数据库2. 查找数据库的UNDO表空间名show parameter undoNAME TYPE VALUE------------------------------------ ----------- ------------------------------undo_management stri
估算undo表空间大小
select (UR*(UPS*DBS))+(DBS*24) as "Bytes"from (select value as URfrom v$parameterwhere name='undo_retention'),(select (sum(undoblks)/sum(((end_time-begin_time)*86400))) as UPSfrom v$undostat),(select value as DBSfrom v$parameterwhere name='db_block_size');[@more@]
FILE_ID + BLOCK_ID -> TABLE_NAME
-- 通过文件id和block_id确定所属的表select * from dba_extentswhere owner = SCHEMA_NAMEand file_id = 6and block_id < 605600and block_id + blocks > 605600;[@more@]
Ora-01632解决办法
alter index xxxxxx STORAGE(MAXEXTENTS UNLIMITED);[@more@]
Oracle中关于函数的使用
在一个select语句中使用函数,对性能危害很大,尽可能少用。在where从句中使用,可能需要用到函数索引提高新能。总之,尽量少用。[@more@]