IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

data copy functionality


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kanisha_prabha

New User


Joined: 10 Mar 2006
Posts: 26

PostPosted: Wed Nov 18, 2009 4:04 pm
Reply with quote

Hi,

I have around 40 DB2 tables which need to be copied to similar tables in another DB2 database. The following are some details -
1. Some of the tables are quite large with no. of rows around 75 million.
2. Average no. of rows will be 10 million.
3. Some of the tables are quite small with no. of rows around 10K
4. I need a consistent data copy approach.
5. The data copy will be dependent on a specific condition which involves a where clause. For some of the tables, the where clause would include 2 (or 3 max.) tables ... such as -
SELECT ...
FROM EMPLOYEE
WHERE EMPNO IN
(SELECT EMPNO FROM PREV_EMPLOYER WHERE ...)

Given the above scenario, could you let me know which is the best possible approach to take for data copy? Should I stick to UNLOAD-LOAD DB2 utility or are there other tools? Should I also consider writing COBOL programs?

Thanks,
- Kanisha
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 18, 2009 4:36 pm
Reply with quote

I would give crossloading a try : publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.ugref/db2z_loadusecrossloaderfunction.htm

But make sure your SQL is optimal. The example you gave doesn't seem to be optimal when you have like x millions prev_employee in the in-list.
Back to top
View user's profile Send private message
kanisha_prabha

New User


Joined: 10 Mar 2006
Posts: 26

PostPosted: Wed Nov 18, 2009 5:31 pm
Reply with quote

What would be the optimal query if there are say 20M that the subquery can return?

Thanks for the cross-loading info.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 18, 2009 6:01 pm
Reply with quote

most likely there is an index on prev_employer(EMPNO)
and/or an index on employee(EMPNO)

It depends on #rows,pages, %rows qualifying of employee ,%rows qualifying of prev_employer, indexes and clustering
which of the following is optimal.

Some access paths will start reading from EMPLOYEE (all rows) and then do the test on prev_employee
others will search on prev_employer and then get all matching employees
other might sort one or two tables and do a merge scan

My guess : this one is the best
Code:
SELECT ...
FROM EMPLOYEE E
WHERE exists ( select 1 FROM PREV_EMPLOYER P WHERE e.EMPNO = p.EMPNO and ...)


Depending on what other fields of prev_employer are in the where clause,
you could add fields to the index making sure you have an index-only access on prev_employer
or have prev_employer clustered on EMPNO

If max 1 prev_employer per employee is possible (considering the extra conditions in the where), then you might just write a join.
Code:
SELECT E.*
FROM EMPLOYEE E
JOIN PREV_EMPLOYER P ON e.EMPNO = p.EMPNO
where P. ...

or
Code:
SELECT E.*
FROM EMPLOYEE E
JOIN PREV_EMPLOYER P ON e.EMPNO = p.EMPNO
                    and P. ...
Back to top
View user's profile Send private message
kanisha_prabha

New User


Joined: 10 Mar 2006
Posts: 26

PostPosted: Wed Nov 18, 2009 6:08 pm
Reply with quote

Thanks! this helps a lot.
Are there any other utilities available - such as Fileaid related copy, etc.?
Just trying to run through all options before I settle with one.

- Kanisha
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 18, 2009 6:58 pm
Reply with quote

I don't know fileaid and have no experience with BMC utilities.

I'm pretty sure that crossloading is faster then writing cobol programs.

It might be cheaper to copy the tables entirely with DSN1COPY and then do deletes on the other database. This could relieve the CPU on your operational data base. (depends on the number of deletes)
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Wed Nov 18, 2009 7:08 pm
Reply with quote

Kanisha,

You could also use FASTUNLOAD & FASTLOAD but those utilities come with Platinum, check with your DBA for the available utilities in your shop.

Sushanth
Back to top
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Thu Nov 19, 2009 12:32 am
Reply with quote

use they BMC unload and load utility which are very faster.

1.Unload using the BMC:
format like:
UNLOAD LOG NO
SELECT * FROM TABLE1 WHEERE EMP_NAME EXIST (
SELECT 1 FROM TABLE2 WHERE EMP_NO=1233
AND EMP_SALARY='50000')

And create unload file say file1

2.Load using BMC
format like
LOAD ORDER NO
CHECKPENDING NO
SYSREC
TABLE3
(EMP_NAME CHAR (4) (1,4),
EMp_SALARY CHAR(4) (5,4))

if you want exact syntax then let me know i will provide you.
Back to top
View user's profile Send private message
kanisha_prabha

New User


Joined: 10 Mar 2006
Posts: 26

PostPosted: Thu Nov 19, 2009 10:47 am
Reply with quote

Hello All,

Thank you for your replies. This helps a lot!

Rgds.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top