Blog
DB2utor

Categories

August 20, 2007

DB2 V9 Logged vs. Not Logged

Have you ever wished you could turn logging off to avoid the overhead? Well now with DB2 V9 for z/OS you can. You can use the ALTER table space NOT LOGGED statement. 

IBM recommends suspending logging for tables that are used in materialized query tables, summary tables, tables where data is propagated and temporary tables that are populated with the result set from a query as an intermediate step in an application.

I was thinking that in a testing environment where I refresh my database with load jobs that it's a waste of resources to perform logging. I would rather run my test without logging and if the database gets corrupted then refresh it with the load files. So I set out to run some performance tests inserting 100,000 rows into an empty table to see how much CPU savings I would get by turning logging off.

The first figure below shows job CSBPION; performed 100,000 inserts with logging turned on. The average CPU time was .003 with a max time of .694, and a total CPU usage of 306.963. 

The second figure below shows job CSBPIOFF; performed the same task with logging turned off. I was surprised to see that the average CPU time was the same .003. However, the overall CPU was lower at 296.277. This was a CPU savings of 3.4 percent. This is a nice savings but you're really getting more savings than just what you see on a given SQL statement.

Logging_on_cpu

Logging_off_cpu 

I don't have a subsystem-performance monitor to show the overall savings. But I can show you some messages logged to my DB2 subsystem showing all of the log records I’m generating, and the log archiving I’m causing. DB2 is spending a lot of resources in the background to manage and take care of the active and archive logs. By suspending the logging I’m improving the overall scalability, especially when large volumes of inserts are being performed.

Notice in the figure below that I generated 313,000 log records, which filled up the active logs and caused archive logs processing.

Log_messages

It may seem that a 3-percent savings to your job isn't much but you also need to consider the savings on logging DASD and reduction of tapes along with all the other CPU resources saved in the subsystem. You may want to consider turning logging off in your testing environment. Please let me know what your experiences are with the ALTER tablespace NOT LOGGED statement.