`

最近。。。。。【201304】-1

 
阅读更多

最近在给同事分析短信工程的时候,发现没有调用返回,但是有取值更新的过程,开始以为是代码问题,后来才发现原来是用的NIO的相关东西,NIO以前很久就注意到了,但是没有具体用过,趁这次机会将NIO的相关东西整理。

最近也加入了两个群一个是oracleDBA和hadoop,两个群分别提到了一些问题,有简单和复杂的,有些我知道,有些我只听说过。

oracleDBA群,这个群里面有高手,也有菜鸟【PS:我也是个菜鸟】:群里说到的问题有count函数,count函数是否会计算null值,count(常数)与count(*)有无差异,日志种类【redo,alter,trc,archive 】及日志的作用,hint,oracle FIRST_ROWS和FIRST_ROWS(N)的区别,DG中  配置日志中  vaild_for,创建表和索引的是否是否会分配段,oracle的表分区,alter database backup controlfile to trace这个命令备份的控制文件【alter database backup controfile to trace as 'd:\abc\xxx.ctl'】,oracle,DHCP【修改主机名称和iP引起oracle没法启动】,CBO don't consider function costs in plans ,undo ,oracle查询sql的执行过程,insert,update,delete 产生redo和undo的大小不一样,rman, rac,游标在SGA中还是PGA中?游标会导致报哪个错?ORA-04030还是ORA-04031 ?怎么解决,索引压缩和表空间压缩表数据压缩,一些系统表V$lock,v$sqltxt等,物化视图。

讨论的时候话的引用FIRST_ROWS(N)

The FIRST_ROWS hint instructs Oracle to optimize an individual SQL statement for fast response, choosing the plan that returns the first n rows most efficiently. For integer, specify the number of rows to return.

For example, the optimizer uses the query optimization approach to optimize the following statement for best response time:

SELECT /*+ FIRST_ROWS(10) */ employee_id, last_name, salary, job_id
  FROM employees
  WHERE department_id = 20;
In this example each department contains many employees. The user wants the first 10 employees of department 20 to be displayed as quickly as possible.

 vaild_for

vaild_for(redo_log_type,database_role)
redo_log_type可设置为:ONLINE_LOGFILE,STANDBY_LOGFILE,ALL_LOGFILES 
database_role可设置为:PRIMARY_ROLE,STANDBY_ROLE,ALL_ROLES  

创建表的是否是否会分配段

By default, the database uses deferred segment creation to update only database metadata when creating tables and indexes. Starting in Oracle Database 11g Release 2
(11.2.0.2), the database also defers segment creation when creating partitions. When a user inserts the first row into a table or partition, the database creates segments for the
table or partition, its LOB columns, and its indexes. 

Deferred segment creation enables you to avoid using database resources
unnecessarily. For example, installation of an application can create thousands of objects, consuming significant disk space. Many of these objects may never be used.

 undo

When a ROLLBACK statement is issued, the database uses undo records to roll back changes made to the database by the uncommitted transaction. During recovery, the database rolls back any uncommitted changes applied from the online redo log to the data files.

 oracle查询sql的执行过程

一个SQL从客户端发送到Oracle服务端,PGA,后台哪些先不说.
然后Oracle服务端接受到后查询Libarary cash查询该条SQL是否已解析,如果已有记录,执行计划啥的都有.
如果末解析,则硬解析,判断语法是否正确,数据字典是否存在相关对象,该用户有没有权限等等..
有问题返回错误,没问题继续..最后生成执行计划.
OK,执行计划有了,就执行吧.
先判断Databuffer cash是否有相关数据块,如果有,继续..再看是否有锁,等待等..
如果buffer cash中没有,需要从数据文件中读,这时候再看buffer够不够用,如果够继续
如果不够...bababa..一些算法..然后该等待等待,如果没问题则从数据文件中开读.
后续就是执行SQL了,排序呀,写undo,写redolog呀,写SCN呀,cKPT呀,DBWR写数据呀等等..
不想讲太细了..

 insert,update,delete 产生redo和undo的大小不一样

DELETE产生的UNDO信息是最多的(记录所有相关字段的值)。
UPDATE产生的UNDO信息在中间的(记录要更新的字段的值)。
INSERT 产生的UNDO信息是最少的(记录要插入的记录行号)。

 游标在SGA中还是PGA中?游标会导致报哪个错?ORA-04030还是ORA-04031 ?怎么解决

游标应该在SGA 和PGA 都有,一个是公有,一个是私有

有这么几个经典错误:
ORA-04030,ORA-04031,ORA-00060,ORA-00600

ORA-04030 out of process memory when trying to allocate string bytes (string,string)

Cause: Operating system process private memory has been exhausted.

如果游标打开的表很大,很多,PGA从1G加到6G,也许还不够
对大数据量的处理,不能用游标一次处理
要用游标多次处理
一次处理2万条,或者5万条,20万条,
第二种情况,是变量表的使用,一次装载了大数据量太大,和游标类似,也是分拆
第三种情况.hash join需要使用 area_hash_size的,这个区域在PGA中

ORA-04031的错误
一般来说,极有可能是硬解析造成的
碰到这个错误,你去查代码,一般都是没有软解析造成的
link也可以软解析

 表数据压缩

 

alter table t1 compress
alter table  t1 move compress
select compression from user_tables where table_name='EMP';

都知道alter table move 或shrink space可以收缩段,用来消除部分行迁移,消除空间碎片,使数据更紧密,但move 跟shrink space还是有区别的。
 Move会移动高水位,但不会释放申请的空间,是在高水位以下(below HWM)的操作。
 而shrink space 同样会移动高水位,但也会释放申请的空间,是在高水位上下(below and above HWM)都有的操作

 不知不觉的写了这么多了,oracleDBA群聊的东西挺多的,还有安装的时候出现的问题,一些查询问题,效率问题,SGA大小的问题等等,就不一一列了,hadoop下次再说

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics