数据仓库 Or SOA
SOA、DataStage、Unix、Java EE、Oracle、Data Migration、Data Integration

2009年8月25日

Sql_Trace File Identifier和Sample Block(抽样表扫描)

Sql_Trace File Identifier

我们设置了sql_trace为true之后,trace file会dump到udump中,但是该目录下也许已经有很多trace file了,或者其他session也设置了sql_trace为true,也在产生trace file。如何能迅速找到你的session产生的trace file呢?我们可以通过如下语句设置Sql_Trace File Identifier:

ALTER SESSION SET TRACEFILE_IDENTIFIER = 'my_trace_id';


这样你的session产生的trace file就会以设置的identifier为后缀。

 

SQL> alter session set tracefile_identifier='test_identifier';

Session altered.

SQL
> alter session set sql_trace=true;

Session altered.

SQL
> select * from dual;

D
-
X

SQL
> alter session set sql_trace=false;

Session altered.

然后我们可以看到udump下生成的trace file文件名为:test_ora_4168_test_identifier.trc

Sample Block

抽样表扫描(sample table scan)只读取一个表的部分数据。其实我们只选择表的部分数据的话,可以用rownum来限制也很方便。但是考虑如下情况:
A表和B表join,我只想A表的部分数据去连接B表,此时用sample就方便的多。如果用rownum就需要用一个subquery。

--用Sample:
select A.id,A.name from A sample block(20),B 
where A.id=B.id
--用Rownum:
select A.id,A.name from (select a.id,a.name from a where rownum<100) A,B 
where A.id=B.id


抽样表扫描有两种形式,一种是抽样表中行数的一个百分比,一个是抽样表中块数的一个百分比。注意都是百分比。语法如下:

SELECT * FROM employees SAMPLE (1);--返回行数乘以1%
SELECT * FROM employees SAMPLE BLOCK (1);--返回块数乘以1%


也可以在视图上使用SAMPLE。


posted @ 2009-08-25 16:01 羽翼渐丰 阅读(398) | 评论 (0) | 编辑 收藏
 

2008年1月15日

ETL时先disable外键约束再load数据
Kimball在他的ETL Toolkit一书中,一直强调:对于有外键约束的表,为了提高load的速度,可以先将外键约束disable,加载完成后再enable(当然另外一个原因是进入数据仓库的数据都是规范的,甚至可以考虑不使用外键约束,即违反约束的数据在Transformation部分就应该解决掉,当然这是设计问题了)。ps:另外两个提高load速度的方法分别为使用sql loader和insert、update分离。当时还不是明白这个过程怎么具体实现,今天看《oracle concept》看到下面话终于明白了一些:
Flexibility for Data Loads and Identification of Integrity Violations
You can disable integrity constraints temporarily so that large amounts of data can be loaded without the overhead of constraint checking. When the data load is complete,you can easily enable the integrity constraints, and you can automatically report any new rows that violate integrity constraints to a separate exceptions table.
看来oracle这点上做的比较完善,还可以将违反完整性约束的数据自动记录到一个exception表中。
posted @ 2008-01-15 16:12 羽翼渐丰 阅读(1467) | 评论 (4) | 编辑 收藏
 

2008年1月8日

删除重复数据的3种方法

今天google分析函数row_number()的时候发现的,觉得很好:

表demo是重复拷贝自dba_objects,有88万左右,不重复的是27323,没有索引
方法一:delete from demo a where a.rowid <> (select max(rowid) from demo b where
b.object_id=a.object_id);
耗时:几个小时以上
方法二: delete from demo where rowid in
(select rid from
(select rowid rid,row_number() over(partition by object_id order by rowid) rn
from demo)
where rn <> 1 );
耗时:30秒
方法三: create table demo2 as
select object_id,owner... from
(select demo.*,row_number() over(partition by object_id order by rowid) rn from demo)
where rn = 1;
truncate table demo; insert into demo select * from demo2; drop table demo2;
共耗时: 10秒,适合大数据量的情况,产生更少回滚量;


学到了分析函数row_number(),对于object_id和rowid也有了一些认识。oracle要学的东西太多了,什么时候是个头啊。上面的方法不是很难理解,但也还没有完全理解,有机会实际试试。

posted @ 2008-01-08 10:04 羽翼渐丰 阅读(426) | 评论 (0) | 编辑 收藏
 

2007年8月13日

在load的时候去掉sequential file的header和footer
今天在论坛看到的方法,先记录下来:
方法一:
在sequential file stage中有个属性可以ignore第一行。对于footer,如果footer使用了与正文不同的格式,可以用使用transformer stage和 @INROWNUM stage来将footer去掉。
方法二:
在sequential file的filter option中使用sed -e '$d' -e '1d'来讲header和footer去掉。
方法三:
写个before job subroutine,可以先对这个文件做各种处理,不过我想也是subroutine中调用DSExecute sed -e '$d' -e '1d'。当然Basic中也有专门对sequential file处理的函数。
posted @ 2007-08-13 19:37 羽翼渐丰 阅读(660) | 评论 (0) | 编辑 收藏
 

2007年8月8日

datastage中Orchadmin命令的使用(转)

Orchadmin is a command line utility provided by datastage to research on data sets.
The general callable format is : $orchadmin [options] [descriptor file]

1. Before using orchadmin, you should make sure that either the working directory or the $APT_ORCHHOME/etc contains the file “config.apt” OR

The environment variable $APT_CONFIG_FILE should be defined for your session.
Orchadmin commands

The various commands available with orchadmin are
1. CHECK: $orchadmin check

Validates the configuration file contents like , accesibility of all nodes defined in the configuration file, scratch disk definitions and accesibility of all the nodes etc. Throws an error when config file is not found or not defined properly

2. COPY : $orchadmin copy
Makes a complete copy of the datasets of source with new destination descriptor file name. Please not that

a. You cannot use UNIX cp command as it justs copies the config file to a new name. The data is not copied.

b. The new datasets will be arranged in the form of the config file that is in use but not according to the old confing file that was in use with the source.

3. DELETE : $orchadmin <> [-f -x] descriptorfiles….
The unix rm utility cannot be used to delete the datasets. The orchadmin delete or rm command should be used to delete one or more persistent data sets.
-f options makes a force delete. If some nodes are not accesible then -f forces to delete the dataset partitions from accessible nodes and leave the other partitions in inaccesible nodes as orphans.
-x forces to use the current config file to be used while deleting than the one stored in data set.

4. DESCRIBE: $orchadmin describe [options] descriptorfile.ds
This is the single most important command.
1. Without any option lists the no.of.partitions, no.of.segments, valid segments, and preserve partitioning flag details of the persistent dataset.
-c : Print the configuration file that is written in the dataset if any
-p: Lists down the partition level information.
-f: Lists down the file level information in each partition
-e: List down the segment level information .
-s: List down the meta-data schema of the information.
-v: Lists all segemnts , valid or otherwise
-l : Long listing. Equivalent to -f -p -s -v -e

5. DUMP: $orchadmin dump [options] descriptorfile.ds
The dump command is used to dump(extract) the records from the dataset.
Without any options the dump command lists down all the records starting from first record from first partition till last record in last partition.
-delim ‘’ : Uses the given string as delimtor for fields instead of space.
-field : Lists only the given field instead of all fields.
-name : List all the values preceded by field name and a colon
-n numrecs : List only the given number of records per partition.
-p period(N) : Lists every Nth record from each partition starting from first record.
-skip N: Skip the first N records from each partition.
-x : Use the current system configuration file rather than the one stored in dataset.

6. TRUNCATE: $orchadmin truncate [options] descriptorfile.ds
Without options deletes all the data(ie Segments) from the dataset.
-f: Uses force truncate. Truncate accessible segments and leave the inaccesible ones.
-x: Uses current system config file rather than the default one stored in the dataset.
-n N: Leaves the first N segments in each partition and truncates the remaining.

7. HELP: $orchadmin -help OR $orchadmin -help
Help manual about the usage of orchadmin or orchadmin commands

posted @ 2007-08-08 15:37 羽翼渐丰 阅读(2261) | 评论 (2) | 编辑 收藏
 

2007年8月2日

trim会drop掉记录
当一条记录过来,某个字段为空,而在transformer中又对该字段trim了,由于该字段为空,不能trim,所以DataStage会认为这是个错误,从而把这个记录drop了,这与实际业务不符合,非主键字段为空并不能就把这条记录drop了。我们可以通过写一个判断来解决该问题:if LK_1.EMAIL <> '' then trim(LK_1.EMAIL) else LK_1.EMAIL
posted @ 2007-08-02 21:01 羽翼渐丰 阅读(538) | 评论 (0) | 编辑 收藏
 
DataStage中可以执行routine,命令行以控制的地方
1 before/after job和before/after stage,可以执行shell,命令行以及一些DataStage API,如DSJobReport
2 job sequence中有个stage,可以在里面写控制job调度的地方
3 每个job的properties中有个job control tab
4 命令行可以执行、导入job等,它通过dsjob实现,在DS Manager的文档中还讲了有专门的命令行来导入job
5 可以编写shell来控制job,对dsjob命令做封装,可以传入参数等。
对于上面这些概念还是很模糊,先记录在此。
posted @ 2007-08-02 19:29 羽翼渐丰 阅读(1799) | 评论 (0) | 编辑 收藏
 
trim全为null的某个字段之后,输出为0
今天又碰到新问题,在transformer中,进去是有很多record,出来之后为0条record,用peek,看了一下,进去的数据的某个字段数据全为null,而在transformer中对此字段trim了,改为不trim就可以了。
posted @ 2007-08-02 15:21 羽翼渐丰 阅读(676) | 评论 (0) | 编辑 收藏
 

2007年8月1日

job一直运行,数据不能插入数据库
今天遇到一个问题,job不停的在那里运行,然后link上的数据显示各个环节都是正确的,包括最后插入数据库的link上也显示了数据,但是最后数据库里并没有数据。在Director的log中,日志在从两个源文件把所有数据load出来完之后,日志就死在那里了。
以前这个job是正确的,昨天由于重新load其中一个源文件的元数据,所以出现了上述问题。所以先前以为是由于load的新的源数据有问题,就从此处来找问题的原因,并且认为可能是改了元数据,在其他地方映射的时候有位置不对的地方,所以整了很久。因为以前是好好的,然后又以为是服务器的问题。

这都是定势思维的错误,然后又一急,所以浪费了很多时间,其实很多时候都是这样,出了问题我们不能理性的好好思考。

其实问题很简单:
如果我们按照正常逻辑来分析的话,既然不能读入数据库,肯定是数据不符合数据库对数据的约束,包括主键啊,非空啊,本问题就是由于在stage的不断流转中产生了很多空格,使得最后待插入的数据长度远远大于数据库中定义的字段长度。由于在那里不断reject,所以影响了速度,job一直在那里运行。最后用APT_STRING_PADDER,将其设为0x0(用null代替空格)搞定。
ps:在插入数据库时使用一个reject文件对查错有好处,这样能看到reject是些什么数据,然后就能知道为什么被reject了。
同时我们可以得出如果最后插入数据库时很多数据被reject,但是你并没有用一个reject文件来接收这些reject掉的数据,将使得job基本处于停滞状态。
posted @ 2007-08-01 17:33 羽翼渐丰 阅读(823) | 评论 (0) | 编辑 收藏
 
DataStage Job重置的三种方法

当一个Job跑到一半终止了要还原,在DS Director中主要有三种方法来还原:
1 Job-----Reset
2 Job-----Clear Status File
3 Job-----Cleanup Resource
具体细节也不懂,有时间慢慢研究

posted @ 2007-08-01 10:17 羽翼渐丰 阅读(1259) | 评论 (0) | 编辑 收藏
 
仅列出标题  下一页
 
<2025年6月>
日一二三四五六
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

 导航

  • BlogJava
  • 首页
  • 发新随笔
  • 发新文章
  • 联系
  • 聚合
  • 管理

 统计

  • 随笔: 18
  • 文章: 2
  • 评论: 8
  • 引用: 0

常用链接

  • 我的随笔
  • 我的评论
  • 我的参与
  • 最新评论

留言簿(3)

  • 给我留言
  • 查看公开留言
  • 查看私人留言

随笔分类

  • DataStage(14) (rss)
  • Java EE(2) (rss)
  • Oracle(1) (rss)
  • SOA (rss)

随笔档案

  • 2009年8月 (1)
  • 2008年1月 (2)
  • 2007年8月 (7)
  • 2007年7月 (6)
  • 2007年6月 (1)
  • 2007年5月 (1)
  • 2006年4月 (1)

搜索

  •  

最新评论

  • 1. re: DataStage中不能删除Job[未登录]
  • 如何执行 DS.CHECKER
  • --Jone
  • 2. re: ETL时先disable外键约束再load数据
  • 我们用到的比较常规的也是disable外键约束,删除index.因为upsert用的就比较少了,至于SQL loader,没怎么用过。
  • --robustyang
  • 3. re: datastage中Orchadmin命令的使用(转) [未登录]
  • 안녕하세요
  • --안녕하세요
  • 4. re: datastage中Orchadmin命令的使用(转) [未登录]
  • SDFSDF
  • --FD
  • 5. re: ETL时先disable外键约束再load数据
  • 您好,关于dagtatage的交流,请加我的MSN:timesheet@live.cn
  • --timesheet

阅读排行榜

  • 1. DataStage中不能删除Job(3750)
  • 2. DataStage官方文档学习笔记(3209)
  • 3. 调用dsjob的shell script(2629)
  • 4. datastage中Orchadmin命令的使用(转) (2261)
  • 5. DataStage中可以执行routine,命令行以控制的地方(1799)

评论排行榜

  • 1. ETL时先disable外键约束再load数据(4)
  • 2. datastage中Orchadmin命令的使用(转) (2)
  • 3. DataStage中不能删除Job(1)
  • 4. DataStage官方文档学习笔记(1)
  • 5. An Eclipse plug-in install problem when language is Chinese(0)

Powered by: 博客园
模板提供:沪江博客
Copyright ©2025 羽翼渐丰