Showing posts with label informatica. Show all posts
Showing posts with label informatica. Show all posts

Saturday, 12 April 2014

ETL load and Linux server performance

Hi Guys,

One of the things that comes into picture is the speed at which a ETL server is creating data file which has to be loaded. If the data file is about 20 GB in size because you are pulling from one database like oracle and loading the data into Teradata. Then the speed at which ETL server is able to pull the data from source becomes very important.

We were noticing that our Server was taking 1 hour to build 1 GB data file which was very slow. So we decided to look into the bandwidth of server. Now considering the IT setup you need to contact Linux server teams to get the information. But knowing few basics System Activity commands helps you to know first hand what is happening on linux server


SAR ( System activity monitor )



Note - we tried using SAR but it was not giving proper information on what amount of data is coming in from network Try using NMON instead 

Long running Loads and one Inactive session

Hi Guys,

Usually by looking at V$session, active session history we are able to find the issue with the load, what is happening. What are the event on which load is waiting like reading from temp space, updating index. However this was one long running load where i was not able to find any information on what is happening for almost half a day as if load is not running. 

Below are 3 of my favourite links from Oracle which will help you understand your ETL loads better than ever. Read it as generic examples. It can be applied to Sql server, Teradata anything



 
Below is my analysis on session which Active session history did not capture 

Note - ACTIVE SESSION HISTORY will capture only if the session is active in case of long loads the session becomes inactive and active session history will not capture it DBA_HIST_ACTIVE_SESS_HISTORY


select * from DBA_HIST_ACTIVE_SESS_HISTORY--- look into this to see which session are running

select event,p1text,p2text,wait_class,blocking_session_status,current_obj#
,pga_allocated,temp_space_allocated from DBA_HIST_ACTIVE_SESS_HISTORY

MASTER QUERY

select count(event),event,current_obj#,object_name
 from DBA_HIST_ACTIVE_SESS_HISTORY,dba_objects  where sql_id = 'ABCCFDFDDD'
 and current_obj# = object_id
and sample_time >= '27-MAR-14 05.00.02.829000000 AM'
 group by event,current_obj#,object_name
 order by 1 desc






 

Tuesday, 1 April 2014

SQL loader does not perform Bulk load when using Pentaho

Hi Guys,

We are trying to bulk load 200 million rows into staging table from source by using Sql Loader direct path load (Bulk load). When we tried using explain plan on the sql fired by SQL loader it uses a hint called SYS_DL_CURSOR which does a conventional load.

Speeds worth to be mentioned  ---SQL loader loads 180k pers seconds which is 11 million per minute.
Db links directly can load -- 3.5 millions per minute . Loaded 180 million in 60 minutes. Some time spent on sql read

Reason -- We were using a option in Pentaho which says load on the fly. So it reads the data from sql and starts loading into oracle as rows come in. The problem is you never have enough rows available for sql loader to go for Bulk load. so it goes for conventional load.

Solution -- Use Automatic load at the end. Any option which creates a Data file on the ETL server and then SQL loader will load from this data file. This will allow sql loader to go for direct load

Note -- The hint  SYS_DL_CURSOR does not matter . Even if the explain plan shows that it is doing a conventional load. You should look into log file of Sql loader you will come to know whether it is doing direct load or conventional load. I have lot of confusion because the explain plan was showing conventional load.

Analysis which was flawed and you might even do this so just noting down. Even this did not work because it never had enough data to do direct load. 


Note - I have tried to manually create SQL loader control file and triggering it from the Linux server. Still it adds the hint

SQL loader control file (.ctl)
load data
 infile '/archive/Load_trial.txt'
 into table ABC
 fields terminated by "," optionally enclosed by '"'
( SRC,
CD ,
SRC_VAL_ID,
GG_CD ,
NMT_IND,
DENOM_IND,
NMT_XCLS_IND,
DENOM_XCLS_IND,
DENOM_XCPT_IND,
RSLT_ANS,
SR_EPSD_ID,
XCLS_RSN_CD,
VAL_TYP_CD,
CREAT_USER_ID,
CREAT_DTM DATE 'mm/dd/yy')

Command to load using SQL loader

sqlldr userid=username/password@servicename control=archive/Trial_load1.ctl log=archive/Trial_logg.log DIRECT=TRUE

 Alternate solution 

Create a procedure using db links which loads data from source schema to target schema. Procedure will perform good because you are eliminating ETL server in the middle. But you will be limited by the speed of the db link connection. DBA will not agree because DB links are a security issue as they expose the data over the network. But keep the procedure ready as contigency measure if load fails and you want urgent load 

Alternate Solution 2 

Data pump.  Pull the tables required from source schema to target schema using data pump and write procedure in target schema to load the data from these pulled source tables. Increadible speed can be achieved.  200  million records can be inserted in less than 1 hour in oracle. 
Data pump is fast and can easily give you speed of 20 million per minute when creating a dump file for import/Export 









Monday, 21 October 2013

ETL tools and Sessions in DB

Hi Guys,

One of the important things to learn about any ETL tool is how it interacts with Database.In any ETL job we have 3 things source transformation(lookup, join, rank etc) and target.Now when anyone says a job is running slow it can be something wrong with source , target or the transformation.

Now transformation is more tool specific how its maintaining cache , best approaches and all that.But source and target are DB dependent. There are number of ways of improving data intake from source and improving data insert into target.So in this article we will discuss that.

Below is a beautiful article on session in oracle and informatica

http://seethehippo.com/the-missing-piece-of-the-jigsaw-understanding-how-informatica-and-oracle-interact/

Other points of interest include

1) What is bulk loading why its is faster
2) Why storing index and table data in different disk speeds up performance
3) How having a large checkpoint interval speeds up performance
4) How much throughput can you expect from your oracle system. and if so what is the benchmark you are expecting for your ETL job ( Consider a simple source to target mapping ) both source and target system are different db .Target is Teradata and source is oracle.We have to load 25 million records ( original time in production system is 40 minutes )



http://oracle-online-help.blogspot.in/2006/12/top-sqls.html--- How to find session id of sql which is taking long time to run

Some General helpful commands

select event, wait_time, seconds_in_wait, state from v$session_wait

select event, total_waits, time_waited from v$session_event

select owner, object_name, object_type from dba_objects

select event, sum(time_waited) from v$active_session_history

select * v$sql

select * from  v$process---- table only available to dba

select ses.sid SID,sqa.SQL_TEXT SQL from v$session ses, v$sqlarea sqa, v$process proc
where ses.paddr=proc.addr and ses.sql_hash_value=sqa.hash_value
and proc.spid=17480;--- this finds the SID by first identifying process id by using TOP processes in linux


select * from v$session -- from the machine name from which query was fired you can get session id

select * from v$session_longops where
sid = 17 and time_remaining > 0'





If you are using sql developer. go to to tools > Monitor session you will get all active session and sql being fired.

select event, total_waits, time_waited from v$session_event  where sid = 135

select event, sum(time_waited) from v$active_session_history where session_id =135 group by event

If you run the sql multiple times the session id will remain same so you will need to use sample time to distinguish old run and new run

select event, sum(time_waited),sample_time from v$active_session_history where session_id =135 group by event,sample_time

select owner, object_name, object_type
from dba_objects
 where object_id in ( select ROW_WAIT_OBJ#
from v$session
 where sid = 134 )

My Super Query to see where is the Bottleneck 

select object_name, object_type,CURRENT_OBJ#, event, sum(time_waited) from v$active_session_history, dba_objects
where session_id =134
and object_id = CURRENT_OBJ#
group by object_name, object_type,CURRENT_OBJ#, event

order by 1

You can try to divide it by 1000 to get

select object_name, object_type,CURRENT_OBJ#, event, (sum(time_waited)/1000)/1000 from v$active_session_history, dba_objects
where session_id =134
and object_id =  CURRENT_OBJ#
group by object_name, object_type,CURRENT_OBJ#, event
order by 1




CREATE SEQUENCE slow_perf
  MINVALUE 1
  START WITH 1
  INCREMENT BY 1
  NOCACHE

  insert into order_details_stage (ORDER_SEQ_KEY,ORDER_DETAIL_CODE ,ORDER_NUMBER,SHIP_DATE,PRODUCT_NUMBER,
  PROMOTION_CODE,QUANTITY,UNIT_COST,UNIT_PRICE,UNIT_SALE_PRICE) select slow_perf.nextval
  ,od.* from gosales.order_details od


------------------------------------------------------------
Query to monitor session got from sql developer ( only if you are not finding option to monitor session in tool you are using)

with vs as (select rownum rnum,
                                                                              sid,
                                                                              serial#,
                                                                              status,
                                                                              username,
                                                                              last_call_et,
                                                                              command,
                                                                              machine,
                                                                              osuser,
                                                                              module,
                                                                              action,
                                                                              resource_consumer_group,
                                                                              client_info,
                                                                              client_identifier,
                                                                              type,
                                                                              terminal
                                                                         from v$session)
                                                             select vs.sid ,serial# serial,
                                                                    vs.username "Username",
                                                                    case when vs.status = 'ACTIVE'
                                                                              then last_call_et
                                                                         else null end "Seconds in Wait",
                                                                    decode(vs.command,
                                                                     0,null,
                                                                     1,'CRE TAB',
                                                                     2,'INSERT',
                                                                     3,'SELECT',
                                                                     4,'CRE CLUSTER',
                                                                     5,'ALT CLUSTER',
                                                                     6,'UPDATE',
                                                                     7,'DELETE',
                                                                     8,'DRP CLUSTER',
                                                                     9,'CRE INDEX',
                                                                     10,'DROP INDEX',
                                                                     11,'ALT INDEX',
                                                                     12,'DROP TABLE',
                                                                     13,'CRE SEQ',
                                                                     14,'ALT SEQ',
                                                                     15,'ALT TABLE',
                                                                     16,'DROP SEQ',
                                                                     17,'GRANT',
                                                                     18,'REVOKE',
                                                                     19,'CRE SYN',
                                                                     20,'DROP SYN',
                                                                     21,'CRE VIEW',
                                                                     22,'DROP VIEW',
                                                                     23,'VAL INDEX',
                                                                     24,'CRE PROC',
                                                                     25,'ALT PROC',
                                                                     26,'LOCK TABLE',
                                                                     28,'RENAME',
                                                                     29,'COMMENT',
                                                                     30,'AUDIT',
                                                                     31,'NOAUDIT',
                                                                     32,'CRE DBLINK',
                                                                     33,'DROP DBLINK',
                                                                     34,'CRE DB',
                                                                     35,'ALTER DB',
                                                                     36,'CRE RBS',
                                                                     37,'ALT RBS',
                                                                     38,'DROP RBS',
                                                                     39,'CRE TBLSPC',
                                                                     40,'ALT TBLSPC',
                                                                     41,'DROP TBLSPC',
                                                                     42,'ALT SESSION',
                                                                     43,'ALT USER',
                                                                     44,'COMMIT',
                                                                     45,'ROLLBACK',
                                                                     46,'SAVEPOINT',
                                                                     47,'PL/SQL EXEC',
                                                                     48,'SET XACTN',
                                                                     49,'SWITCH LOG',
                                                                     50,'EXPLAIN',
                                                                     51,'CRE USER',
                                                                     52,'CRE ROLE',
                                                                     53,'DROP USER',
                                                                     54,'DROP ROLE',
                                                                     55,'SET ROLE',
                                                                     56,'CRE SCHEMA',
                                                                     57,'CRE CTLFILE',
                                                                     58,'ALTER TRACING',
                                                                     59,'CRE TRIGGER',
                                                                     60,'ALT TRIGGER',
                                                                     61,'DRP TRIGGER',
                                                                     62,'ANALYZE TAB',
                                                                     63,'ANALYZE IX',
                                                                     64,'ANALYZE CLUS',
                                                                     65,'CRE PROFILE',
                                                                     66,'DRP PROFILE',
                                                                     67,'ALT PROFILE',
                                                                     68,'DRP PROC',
                                                                     69,'DRP PROC',
                                                                     70,'ALT RESOURCE',
                                                                     71,'CRE SNPLOG',
                                                                     72,'ALT SNPLOG',
                                                                     73,'DROP SNPLOG',
                                                                     74,'CREATE SNAP',
                                                                     75,'ALT SNAP',
                                                                     76,'DROP SNAP',
                                                                     79,'ALTER ROLE',
                                                                     79,'ALTER ROLE',
                                                                     85,'TRUNC TAB',
                                                                     86,'TRUNC CLUST',
                                                                     88,'ALT VIEW',
                                                                     91,'CRE FUNC',
                                                                     92,'ALT FUNC',
                                                                     93,'DROP FUNC',
                                                                     94,'CRE PKG',
                                                                     95,'ALT PKG',
                                                                     96,'DROP PKG',
                                                                     97,'CRE PKG BODY',
                                                                     98,'ALT PKG BODY',
                                                                     99,'DRP PKG BODY',
                                                                     to_char(vs.command)) "Command",
                                                                    vs.machine "Machine",
                                                                    vs.osuser "OS User",
                                                                    lower(vs.status) "Status",
                                                                    vs.module "Module",
                                                                    vs.action "Action",
                                                                    vs.resource_consumer_group,
                                                                    vs.client_info,
                                                                    vs.client_identifier
                                                               from vs
                                                              where vs.USERNAME is not null
                                                                and nvl(vs.osuser,'x') <> 'SYSTEM'
                                                                and vs.type <> 'BACKGROUND'
                                                                order by 1