Question

Running DB2 9.7.5 LUW on Windows 2008. I'm transfering data hourly from a MS SQL 2008 server over the WAN. I read the data from MS SQL, parse the data and batch insert into a work table in DB2, then in DB2 merge the data from the work table to the master table. Once the merge is done, I clear the work table to prepare for next load. I've noticed that my log files are very big. Since the db session is open and closed during data exchange, temporary tables are not suitable, hence the use of work tables. The data is transfered by a java app which I made.

I don't need to have the work table transactions logged. I've read this article from IBM and found that logging doesn't happen in the same work unit as when the table was created.

Using CREATE TABLE...NOT LOGGED INITIALLY and ALTER TABLE...NOT LOGGED INITIALLY really work? From what I understand once you have created the table that logging begins after the first commit?

Do I need to create the table everytime with not logged and then clear it with alter table not logged? Is there a better way?

Was it helpful?

Solution

You don't need to create the table every time. You issue ALTER TABLE...NOT LOGGED INITIALLY before inserting data into the table in the same unit of work (transaction).

You don't indicate how you clear the work table; I hope you are using the TRUNCATE TABLE statement, which is more efficient than dropping table records and minimizes logging.

OTHER TIPS

You need not to alter the table for not logged initially. You just need to activate it everytime using alter table tablename activate not logged initially.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top