01 2014 档案
摘要:转自 http://www.dbsnake.net/oracle-hash-join.html哈希连接(HASH JOIN)是一种两个表在做表连接时主要依靠哈希运算来得到连接结果集的表连接方法。在Oracle 7.3之前,Oracle数据库中的常用表连接方法就只有排序合并连接和嵌套循环连接这两种,但这两种表连接方法都有其明显缺陷。对于排序合并连接,如果两个表在施加了目标SQL中指定的谓词条件(如果有的话)后得到的结果集很大且需要排序的话,则这种情况下的排序合并连接的执行效率一定是很差的;而对于嵌套循环连接,如果驱动表所对应的驱动结果集的记录数很大,即便在被驱动表的连接列上存在索引,此时使用嵌套
阅读全文
摘要:转自 http://www.cnblogs.com/helong/articles/2088535.html我们以Oracle自带的表来做例子主要两张表:dept、emp一个是部门,一个是员工表结构如下:empnamenull?TypeEmpnonot nullnumber(4)enamevarchar2(10)jobvarchar2(9)mgrnumber(4)hiredatedatesalnumber(7,2)commnumber(7,2)deptnonumber(2)deptnamenull?Typedeptnonot nullnumber(2)dnamevarchar2(14)logv
阅读全文
摘要:转自 http://blog.csdn.net/zengmuansha/article/details/7492826在看分区的执行计划当中 说明字段有各种不同的分区操作其中有两个PARTITION RANGE ITERATORPARTITION RANGE singleITERATOR的成本高于S...
阅读全文
摘要:转自 http://blog.csdn.net/zengmuansha/article/details/74880181 嵌套连接成本外部表成本+内部表成本*外部表数据行| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |---------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 10000 | 312K| 1338K (2)| 04:27:46 || 1 | NESTED LOOPS
阅读全文
摘要:转自 http://blog.csdn.net/zengmuansha/article/details/7490234SQL> select * from t1 where a execute dbms_stats.gather_table_stats('ZENGMUANSHA','T1');SQL> select column_name,NUM_NULLS,NUM_DISTINCT,density from user_tab_col_statistics where table_name='T1';COLUMN_NAMENUM_NU
阅读全文
摘要:转自 http://blog.csdn.net/zengmuansha/article/details/7490008索引和表查不多的物理对象,都是存储的数据.索引存储的是分支+索引列+ROWID+指针.因为是快速全索引扫描,就没有必要从分支跳到另外个分支,直接从根块到叶块,从叶块的前后指针扫描到尾巴上!因此其成本和全表扫描方式是一样的,那么公式也是一样的.这样我们继续使用上面用到的表和数据.快速索引扫描SQL> create index t1_ind on t1(a);Index createdSQL> select leaf_blocks from dba_indexes wh
阅读全文
摘要:转自 http://blog.csdn.net/zengmuansha/article/details/7489822公式:According to the CPU costing model:Cost = (#SRds * sreadtim +#MRds * mreadtim +~~~~~~~~~~~~~~~~~~~~~~~~~~~~来自于cost-basedoracle书中#CPUCycles / cpuspeed) / sreadtimwhere#SRDs - number of single block reads -–单块读取次数#MRDs - number of multi blo
阅读全文
摘要:转自 http://blog.csdn.net/zengmuansha/article/details/8601663简单点说,在oracle的block上都有活动事务的标志的,如果一个事务commit后,由于某些block在commit之前已经写回datafile,或者事务影响到的block数过多,则commit的时候只会清理undo segment header中的事务表信息,data block上的事务标志不会清除,在否则代价过高。那么在一些读取这些block时,需要将这些事务标志进行清除,就是延迟块清除块清除即清除数据块上与“锁定”有关的信息。Oracle的锁机制是一种轻量级的锁定机制
阅读全文
摘要:转自http://blog.csdn.net/zengmuansha/article/details/7448723hash_join可以通过no_swap_join_inputs/swap_join_inputs来强制控制build表,配合leading可以控制多表之前的连接顺序----------------创建4个测试表create table t1 as select * from dba_objects;create table t2 as select * from dba_objects;create table t3 as select * from dba_objects;c
阅读全文
摘要:转自 http://blog.csdn.net/zengmuansha/article/details/5096655表连接方式及使用场合NESTED LOOP对于被连接的数据子集较小的情况,nested loop连接是个较好的选择。nested loop就是扫描一个表,每读到一条记录,就根据索引去另一个表里面查找,没有索引一般就不会是 nested loops。一般在nested loop中, 驱动表满足条件结果集不大,被驱动表的连接字段要有索引,这样就走nested loop。如果驱动表返回记录太多,就不适合nested loops了。如果连接字段没有索引,则适合走hash join,因为
阅读全文
摘要:Oracle 10G 获得执行计划 有1 SQLPLUS 2 PL/SQLDEVELOPER 工具 3 TOAD2 PL/SQL DEVELOPER[sql]view plaincopyprint?SELECTcount(*)FROMuser_beh_sum_day_201203aWHEREa.operid=1006ANDa.channelid=12选择了这几个观察指标分别是1 Description 说明2 Depth 深度3 Object Name 对像4 Operation 操作5 Cost 成本6 Cardinality 基数7 Filter predicates 过滤谓词8 acce
阅读全文
摘要:转自 http://blog.csdn.net/zengmuansha/article/details/7332065在Oracle中,确定连接操作类型是执行计划生成的重要方面。各种连接操作类型代表着不同的连接操作算法,不同的连接操作类型也适应于不同的数据量和数据分布情况。无论是Nest Loop ...
阅读全文
摘要:转自 http://blog.csdn.net/zengmuansha/article/details/74845601 公式: 基数= 连接选择率*过滤条件1基数+过滤条件2的基数连接选择率=((num_rows(表1)-num_nulls(表1连接字段))/num_rows(表1))*((num_rows(表2)-num_nulls(表2连接字段))/num_rows(表2)) /Greater(num_distinct(表1连接字段),num_distinct(表2连接字段))[sql] view plaincopyprint?createtablet1asselecttrunc(dbm
阅读全文
摘要:转自 http://blog.csdn.net/zengmuansha/article/details/7484523Oracle 执行计划(2)-基数执行计划的cardinality列。基数是说从数据表,结果集或者索引返回多少行数据。基数=表行数据*选择率。所以讲基数重点是讲选择率,选择率的计算!版本10G 默认 表空间信息:TABLESPACE_NAMEUSERSBLOCK_SIZE8192EXTENT_MANAGEMENTLOCALALLOCATION_TYPESYSTEMSEGMENT_SPACE_MANAGEMENTAUTODEF_TAB_COMPRESSIONDISABLEDBIG
阅读全文
摘要:转自 http://blog.itpub.net/23073818/viewspace-1073548/有改动在归档模式下移动数据文件:步骤如下采用offline的方式1,将表空间offlinealter tablespace tablespace_name offline;2,cp文件到新的目录并rename修改控制文件3,将相应表空间online当然这种方式同样会影响期间的表空间使用。--实际操作如下:操作系统版本:oracle@ntsmshost:~$ uname -aLinux ntsmshost 3.0.0-25-server #41-Ubuntu SMP Mon Aug 13 18
阅读全文
摘要:转自 http://blog.csdn.net/tianlesoftware/article/details/5630888在Oracle10g之前,优化SQL是个比较费力的技术活,不停的分析执行计划,加hint,分析统计信息等等。在10g中,Oracle推出了自己的SQL优化辅助工具:SQL优化器...
阅读全文
摘要:转自 http://www.itpub.net/thread-1784848-1-1.html因为优化器还不够强大,还有很多限制,或者因为一些逻辑原因,分析认为SQL要走索引比较好,但是事实却无法正确利用索引。这时候,除了给ORACLE需要的统计信息之外,写的SQL必须要能够给优化器足够多的额外有效...
阅读全文
摘要:ORA-29857: 表空间中存在域索引和/或次级对象删除表空间时报错ORA-29857: 表空间中存在域索引和/或次级对象,查了一下,可能是因为是某个用户默认表空间的原因。所以需要先删除用户,然后再执行表空间的删除操作。在sqlplus执行查询语句select username,default_tablespace from dba_users发现确实有用户的默认表空间是我要删除的表空间,然后drop user 用户名 cascade ;然后重新执行表空间的删除操作drop tablespace 表空间名 including contents and datafiles cascade co
阅读全文
摘要:转自 http://www.eygle.com/archives/2004/12/rman_crosscheck.html当手工删除了归档日志以后,Rman备份会检测到日志缺失,从而无法进一步继续执行。所以此时需要手工执行crosscheck过程,之后Rman备份可以恢复正常。1.Crosschec...
阅读全文
摘要:转自 http://blog.chinaunix.net/uid-7655508-id-3763232.html 在ITPUB上遇到一个很有意思的问题(http://www.itpub.net/thread-1796130-1-1.html),对于表T,有object_id,按照where object_id =:oid查询,如果传入的oid是NULL,则查询全部(希望走全表扫描),相当于FROM t WHERE 1=1,如果object_id传入非NULL值(希望走索引扫描),则执行查询FROM t WHERE object_id =:oid,这是常见的根据传入的值不同,执行不同条件查询的语
阅读全文
摘要:今天在调一些固定的SQL,调整一下写法,加点注释,改几个别名什么的,本身没什么事情。结果在其中某一个SQL的时候,忽然卡住了。一共是三个左连接一个EXISTS,每张表都不超过一百万行。按道理说,这种SQL就算慢,也不会超过一分钟,就得出结果。结果执行的效果让我很困惑。头一次执行的时候很快,非常快,两秒出结果。再执行一次,就要很久了,反正我是没等到过结果。最长一次等了半小时,我中午饭都吃完了思密达。。。看计划,没问题,一点问题都没有。看数据库的负载,也没什么问题。可以说库是很闲的。那这是为啥?能执行,能有速度快的,说明Oracle能找到基本正确的计划。但是为什么第二次会慢呢?一下子就想到了一个新
阅读全文
摘要:转自 http://www.itpub.net/thread-719692-1-1.html摘要一组连续的数,去掉中间一些数,如何求出剩下的数的区间(即号段)?知道号段的起止,如何求出该号段内所有的数?知道一个大的号段范围和已经取过的号段,如何求出可用的号段?利用Oracle提供的强大的查询功能以及分析函数,我们可以很轻松的解决上述问题。关键词:号段选取、连续数、断点、层次查询、分析函数、connect by、rownum、level、lead、lag1. 问题的提出在实际工作中,我们常常会碰到号段选取的问题,例如: 一组连续的数,去掉中间一些数,要求出剩下的数的区间(即号段)例...
阅读全文
摘要:转自 http://blog.itpub.net/94317/viewspace-797083/昨天在itpub看到这个帖子, 问题觉得有意思,, 就仔细想了想. 也给出了一种解决办法..:-)问题求助,请高手指点..我有一个表结构,fphm,kshm2014,000000012014,000000022014,000000032014,000000042014,000000052014,000000072014,000000082014,000000092013,000001202013,000001212013,000001222013,000001242013,00000125(第二个字
阅读全文
摘要:数据库环境LEO1@LEO1> select * from v$version;BANNER--------------------------------------------------------------------------------Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionPL/SQL Release 11.2.0.1.0 - ProductionCORE 11.2.0.1.0 ProductionTNS for Linux: Version 11.2.0.1
阅读全文
摘要:转自 http://blog.itpub.net/26686207/viewspace-754644/新年新说:新年伊始,2012年过去了,我们又踏上了2013年的,回顾2012我们付出了很多,辛勤和汗水换来了知识和友谊,当我们技术成长的时候我才发现长路漫漫,唯心可敬。一份耕耘一份收获,走技术之路是艰辛的孤独的漫长的,在此向刚入门的小伙子们,说一说心得体会。做好心理准备,可能你为了小小的虚荣心,为了生活所迫,才走上此路,但你也要走的洒脱走的稳健,当你站在第一个里程碑时回顾来时路,你会发现你的收获是值得的,你的付出是有意思的,你才能有继续走下去的勇气。我要感谢Alantanytigerfish海
阅读全文
摘要:转自 http://blog.itpub.net/26686207/viewspace-767750/s tablesALL_USERS Information about all users of the databaseALL_VIEWS Text of views accessible to the userUSER_AUDIT_CONNECT Audit trail entries for user logons/logoffsUSER_AUDIT_OBJECT Audit trail records for statements concerning objects, sp...
阅读全文
摘要:转自 http://blog.chinaunix.net/uid-7655508-id-4061354.html在ORACLE里,一般认为''与NULL是等价的,除了一些特别的语法,比如有id is null,但是没有id is '',以及''作为字符类型的特殊性,在decode等函数要求类型匹配的时候,与NULL可能不等价。本篇文章主要说明下''与NULL在SQL优化器中也有很大的区别,如果不了解这个区别,很可能SQL语句的性能,将要陷入灾难境地。此问题来源于:http://www.itpub.net/thread-183824
阅读全文
摘要:转自 http://blog.csdn.net/huanghui22/article/details/1347559#comments一.B树索引0. B树索引中不存在非唯一的条目。1)在非唯一索引中,ORACLE会把rowid作为一个额外的列追加到键上,使得键唯一。Exp:create index I on T( x , y ) ,从概念上讲就是Create unique index I on T(x , y , rowid)。ORACLE会首先按索引键值排序,然后再按照rowid升序排序。2)在唯一索引中,数据只按索引键值排序。1.大多数情况下,B树索引的高度都是2或者3,所以一般情况下,
阅读全文
摘要:转自 http://www.dba-oracle.com/t_row_number_analytic_function.htmQuestion:I need to run a SQL query to retrieve the top-10 rows from a large table and I heard that therow_numberanalytic function can help. How do you userow_numberto get top-n rows, and why is it better or worse than the rank function?A
阅读全文
摘要:转自http://www.dba-oracle.com/t_sql_tuning_rownum_equals_one.htmMany people forget that the Oracle SQL optimizer is an in-house computer program, written by software engineers, and it’s not something where the rules of scientific endeavor apply.Oracle SQL has lots of special nuances and there are many
阅读全文
摘要:整理自 http://blog.csdn.net/huanghui22/article/details/1595169实际应用中我们可以通过sum()统计出组中的总计或者是累加值,具体示例如下:1.创建演示表createtableempasselect*fromscott.emp;altertableempaddconstraintemp_pkprimarykey(empno);createtabledeptasselect*fromscott.dept;altertabledeptaddconstraintdept_pkprimarykey(deptno);2. sum()语句如下:sele
阅读全文
摘要:转自 http://www.oracle.com/technetwork/issue-archive/2009/09-jan/o19asktom-086775.htmlOur technologist samples dynamically, considers usage, and sets levels.My questions are related to dynamic sampling. What does it really do, when would I consider using it, and what are the meanings of all the differ
阅读全文
摘要:转自 http://blog.csdn.net/tianlesoftware/article/details/5695784一. 官网说明 在DBCA 建库的时候,有提示让我们选择连接类型,这里有两种类型:专用服务器模式和共享服务器模式。默认使用专用模式。如下图:Oracle 官方文档对这两种文档的说明如下:About Dedicated andShared Server Processeshttp://download.oracle.com/docs/cd/B28359_01/server.111/b28310/manproc001.htm OracleDatabase creates se
阅读全文
摘要:Oracle Database creates server processes to handle the requests of user processes connected to an instance. A server process can be either of the following:Adedicated server process, which services only one user processAshared server process, which can service multiple user processesYour database is
阅读全文
摘要:1. Which is the main difference between a MTS (Shared Server) and Dedicated Server?In aShared Serverarchitecture MANY sessions (user connections) have ONE server process associated.In aDedicated Serverarchitecture ONLY ONE sessions (user connections) have ONLY ONE server process associated.Because a
阅读全文
摘要:转自 http://m.blog.csdn.net/blog/gujia200808/5794864彻底理解初始化参数SERVICE_NAMES和客户端TNS中SERVICE_NAME彻底理解初始化参数SERVICE_NAMES和客户端TNS中SERVICE_NAME本文可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明http://blog.itpub.net/post/11/30851. SERVICE_NAMES与LISTENER初始化参数SERVICE_NAMES默认为INSTANCE_NAME,后台进程PMON自动在服务器监听器中注册该SERVICE_NAMES
阅读全文
摘要:转自 http://www.xifenfei.com/3090.html发现监听进程监听8080和2100端口--监听端口[oracle@xifenfei ~]$ netstat -nap|grep tnslsnr(Not all processes could be identified, non-owned process infowill not be shown, you would have to be root to see it all.)tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 29866/tnslsnrtcp 0 0 0.0.0.0:1521
阅读全文
摘要:http://technet.microsoft.com/en-us/library/ms187961%28v=sql.105%29.aspxIn SQL Server, many administrative and informational activities can be performed by using system stored procedures. The system stored procedures are grouped into the categories shown in the following table.In This SectionCategory
阅读全文
摘要:钻自 http://technet.microsoft.com/en-us/library/ms175481%28v=sql.105%29.aspxSQL Server Profiler lets you record events as they occur in an instance of t...
阅读全文
摘要:http://www.sql-server-performance.com/2005/transferring-statistics/Many production databases today are in the tens or hundreds of gigabytes in size. That size is not a problem for production hardware. However, developers generally like to work on their personal computers, including notebooks with li
阅读全文
摘要:http://technet.microsoft.com/en-us/library/ms174215(v=sql.105).aspxDatabase Engine Tuning Advisor provides new features that enable both novice and experienced database administrators to tune databases for better query performance. The following sections list and describe the Database Engine Tuning
阅读全文
摘要:The process of tracing with SQL Trace varies depending on whether you create and run your trace by using Microsoft SQL Server Profiler or by using system stored procedures.As an alternative to SQL Server Profiler, you can use Transact-SQL system stored procedures to create and run traces. The proces
阅读全文
摘要:转自 http://blog.csdn.net/pandakong/article/details/9154277补丁总是会一遍又一遍的打,越打越多有时候,就担心有人不小心把高版本的class打到低版本jre运行的环境中简单写了点代码,检查文件夹中class的版本号[java] view plain...
阅读全文
摘要:1 --常用SQL系统信息与搜集方法 P455 第14章 Windows事件日志,SQL ErrorLog,性能监视器 2 3 --作为一个可支持性比较高的应用软件,SQL在最近的几个版本里, 4 --不断地开放出系统状态记录新功能,供DBA实时地了解SQL当前的运行 5 --状态,或者分析过去某一段时间内的运行历史。所以关于SQL的系统 6 --运行信息,是非常丰富的。 7 8 --在这些信息里,有些概况性信息是SQL会自动记录的。例如SQL什么时候 9 --开启的,上次是怎麽被关闭的,是否出现过严重的系统异常,从SQL服务 10 --启动以来,数据库做过的读写总量...
阅读全文
摘要:http://www.tuicool.com/articles/aY3A32性能监视SQL Server 2008监视本质上可以分为5个区域:系统资源;SQL Server自身;数据库;数据库应用程序和网络。监视和优化SQL 的策略是相当简单的,分为以下几步:创建一个性能基准;完成定期性能审核;作出改动并评估他们的影响;重设基准那么基准中应该都包含些什么呢?下面是一个基准和性能审核对象和进程的列表:计数器:计数器包括Processor:%Processor Timer计数器,它显示了处理非限制线程所用时间的总百分比;Process:%Processor Time计数器用来确定总处理时间中有多少
阅读全文
摘要:http://technet.microsoft.com/en-us/library/ms191427(v=sql.105).aspxhe Showplan Statistics Profile event class occurs when MicrosoftSQL Server executes an SQL statement. Include thisevent class to identify the Showplan operators on MicrosoftSQL Server 2000 or MicrosoftSQL Server7.0. This event class
阅读全文
摘要:http://technet.microsoft.com/en-us/library/ms186265(v=sql.105).aspxAdds or removes an event or event column to a trace.sp_trace_seteventmay be executed only on existing traces that are stopped (statusis0). An error is returned if this stored procedure is executed on a trace that does not exist or wh
阅读全文
摘要:http://technet.microsoft.com/en-us/library/ms188662(v=sql.105).aspxThis topic describes how to use stored procedures to create a trace.To create a traceExecutesp_trace_createwith the required parameters to create a new trace. The new trace will be in a stopped state (statusis0).Executesp_trace_setev
阅读全文
摘要:http://technet.microsoft.com/en-us/library/ms191006(v=sql.105).aspxMicrosoft SQL Server provides Transact-SQL system stored procedures to create traces on an instance of the SQL Server Database Engine. These system stored procedures can be used from within your own applications to create traces manu
阅读全文