-1

Why the not logged initially option during the data movement is faster than using the LOAD utility in DB2?

Not logged initially Method:

db2 alter table tablename activate not logged initially

db2 insert into table tablename select * from tbname

Load Utility:

db2 declare source cursor for select * from tablename

db2 load from source of cursor insert into tablename nonrecoverable
mustaccio
  • 18,234
  • 16
  • 48
  • 57
Tom123456
  • 77
  • 1
  • 9

1 Answers1

1

Based on your database size and performance question I am going to assume that you are using the Database Partitioning Feature (DPF) with DB2.

When you perform INSERT INTO ... SELECT, this occurs in parallel on all database partitions – each partition is working independently. With logging turned off, this will be quite fast (albeit dangerous – if there is a problem, the not-logged-initially table will have to be dropped and recreated).

When you use LOAD FROM CURSOR, all of the database partitions execute the SELECT statement and return the rows to the coordinator partition, which then feeds them into the LOAD utility. The LOAD utility then performs hash partitioning to send the data back to all of the database partitions again. As you can imagine, with a large volume of data, shipping all of this data back and forth can be quite inefficient.

Ian Bjorhovde
  • 10,916
  • 1
  • 28
  • 25
  • Thanks Lan for your response! Kindly let me know which could be the favourable way to make replica of tables. We need to do this activity every month. – Tom123456 Jun 25 '14 at 09:11
  • Either method is OK, which you choose should be a function of your application's specific requirements. – Ian Bjorhovde Jun 25 '14 at 18:06