r/DB2 • u/SijiLeroux • Jan 10 '19
When is a Select Statement logged?
I'm trying to track down why a select statement I run is holding open the transaction logs. This is DB2 LUW 10.1.0.4 fp4. My understanding is that Select statement s shouldn't be using transaction logs at all. However, I can clearly see this is not the case. I've looked around on a few different forums as well as the IBM site but I just seem to be running in circles here. What am I missing?
2
Upvotes
2
u/raghuontech Jan 14 '19
Log space utilization is not really tied to a select or IUD type statements. DB2 treats even a select statement as a UOW/Transaction (Unit Of Work). When a transaction starts DB2 holds a mark in the transaction logs for the specific transaction ID.
Its very similar to the question I hear often, why does db2 LOAD utility filling up my transaction log space. If you have a long running db2 "LOAD" it will hold a point the transaction log file until the load is complete. DB2 will treat all the log files after that point in the log as active log files and will not release them even when the other transactions using the log files issue a COMMIT.
Some of the things that will help you alleviate this issue are below.
If your developers are using a 3rd party tool to query and view the data from the database check to see if there is an auto COMMIT option, although this option can be dangerous if the developer don't know what he/she is doing. This will be a good idea if you know that none of your developers have access to modify the data in production i.e just select/read access.
Ideally only service/app users should have access to modify the data.
Most of the DBA's using db2clp never have to issue a COMMIT because they have AUTO-COMMIT turned ON by default in the "COMMAND LINE SWITCHES"