增量聚集

增量聚集(Incremental Aggregation)

PowerCenter Server 运行你增量的修改目标(target),而不是强迫process整个源和重新计算。

用增量聚集的条件:

  • Mapping 包含聚集函数;
  • 源(source)只做增量的改变;
  • 增量的改变能被捕捉。如果用时间戳等。

不用增量聚集的情况:

  • 不能捕捉到新的源数据
  • 源数据的改变会导致很多的目标数据的改变,如改变超过半数的目标数据,则不应该用增量聚集
  • Mapping中包含百位数(percentile)或中线(median)函数

增量策略中的一些决策条件:

  • 还原、重载、卸载的错误策略(error-un/loading data strategies)
  • 历史跟踪的保留,即什么时候加载了什么数据
  • 要为共用的mapping缓慢的改变维度的Informatica Wizards,应该是说分为多步或多个mapping实现改变过程

源的分析(Source Analysis)

可能的场景:

  • Delta Records——源数据只包括新的或修改的数据。只要对所有的数据进行插入或修改就可以了
  • Record indicator or flags——源数据包含一个标志列用来标志增删改。
  • Date stamped data——时间戳数据。根据最后一次加载的时间或有效时间范围进行加载。
  • Key values are present——根据主键去判断是否已经加载了。如果已经加载了则判断是否数据已经改变了。
  • No Key values present——创建代理主键(Surrogate keys),并将有效数据插入到数据仓库中。

识别需要比较的数据

  • 比较目标表。判断是否已经存在。如果不存在,则插入新的记录,否则,判断是否需要修改,插入或删除。在Delta loads、timestamps、keys和surrogate keys中用到
  • Record indicators。在检查哪些目标不需要修改时很有好处,只要注意存在的数据的修改和删除,以及数据的插入成功以否。需要注意的是对错误的管理。

决定比较的方法

  • Joins of Sources to Targets。数据直接跟目标数据进行连接或用多个源数据连接好的数据去管理。需要注意数据量是否在可管理范围。
  • Lookup on target。检查目标数据库的主键或关键列。需要考虑缓存和索引的可能性。
  • Load table log。生产一个已经插入到目标表的数据日志表,用这个去joins或lookup。如把表的主键存到一张表中,再用这张表去比较。

基于加载策略的源

  • 将增量加载的数据放在单一的文件或表中。对大数据量的加载(bulk load),并不必处理源的加载过程(process)和对源数据进行排序。

加载方法:直接加载到数据仓库中。

  • 时间戳数据。加载上次加载之后的数据,可能是时间或有效标志。

加载方法:对关系型数据,选择有效时间内的 数据进行加载,也可以在视图中进行选择,而不是集成在mapping中。把加载策略放到ETL组件中对ETL开发者和元数据来说更具可行性和可控制性。对非关系型数据,筛选有效的数据,在加载后修改筛选条件去删除旧的数据。对有效时间,可以放到mapping的变量中,也可以放到控制表中。

  • 基于keys或记录信息修改的数据。根据主键去判断是否存在,如果存在,去判断是否需要修改或删除。

加载方法:Join目标表去判断哪些数据是新的。也可以去lookup目标表来判断是否存在。

基于加载策略的目标

  • 直接加载到目标。可能用在大量数据加载时,需要考虑错误、还原、更新策略。
  • 用外部加载工具,加载到flat files和用大数据量加载(bulk load)。这个方法减少了load的时间和提供了维护历史数据的方法。大多数只用在更新(update)到数据仓库的时候
  • 加载到镜像数据库。可以避免活动数据库的停机时间(down time)。

I had seen several posts related to Incremental Aggregation in Informatica-I group of www.ittoolbox.com. Below is the step by step process to apply incremental aggregation.

 

Incremental aggregation is used when you need to apply captured changes in the source to aggregate calculations in a session. If the source changes only incrementally and you can capture changes, you can configure the session to process only those changes. This allows the Informatica Server to update your target incrementally, rather than forcing it to process the entire source and recalculate the same calculations each time you run the session.

 

When you run an incremental aggregation session for the first time, IS process the entire source and creates Data File and Index File in cache directory specified.  The Integration Service names the index file as PMAGG*.idx* and the data file as PMAGG*.dat*.

 

Note:

1.  If you are using percentile or median functions, do not use Incremental Aggregation because IS uses system memory to process these functions in addition to the cache memory configured in the session properties.

2.  Don’t move the aggregate files without correcting the configured path or directory for the files in the session properties.

3. Don’t change the configured path or directory for the aggregate files without moving the files to the new location.

4. Don’t delete cache files or change the number of partitions.

 

Step-by-step Process

 

Source Table

empno

sal

deptno

hire_dt

1

2000

10

Nov 29 2010

2

5000

10

Nov 29 2010

3

8000

10

Nov 29 2010

4

2000

20

Nov 29 2010

5

10000

20

Nov 29 2010

6

12000

30

Nov 29 2010

7

22000

30

Nov 29 2010

8

31000

30

Nov 29 2010

9

1000

10

Nov 30 2010

10

1000

10

Nov 30 2010

11

1000

30

Nov 30 2010

 

Below is the flow of mapping

 

 

The data will be pulled from the source on the basis of hiredate. We will create a parameter to pass hiredate as shown below.

 

Filter transformation

 

Filter transformation will be used to filter the data on the basis of hiredate as shown below

 

Aggregator Transformation

 

Aggregator transformation will aggregate department wise salary.

 

Update Strategy

 

Update Strategy transformation is used to flag rows for update.

 

Once you are done with the mapping design, next step is to create a Session and Workflow.

 

Create a session and set the properties for Target as shown below.

 

Check the below session properties as shown below.

 

Set the value of $$hiredt parameter to 11/29/2010 and run the session. You will get the below rows in target.

 

Deptno

Sal

10

15000

20

12000

30

65000

 

After first run, go to session properties and uncheck the option “Reinitialize aggregate cache” as shown below.

 

Set the value of $$hiredt parameter to 11/30/2010 and run the session again. Now the value in target table will be as shown below.

Deptno

Sal

10

17000

20

12000

30

66000

 

Common Error:

 

Below is the common error person used to get while using Incremental Aggregation.

 

TE_7051 : Aggregate Error: Index file timestamp is earlier than the timestamp of AGG transformation or Mapping

TE_7029 : Aggregate Information: Creating New Index and Data Files

 

Resolution:

This error occurs when the mapping associated to the incremental aggregation session is modified. Make sure that the associated mapping should not be modified.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值