Skip to content
Advertisement

Is a commit needed on a select query in DB2?

I have a vendor reporting product executing queries to pull report data, no inserts, no updates just reading data.

We have double our heap size 3 times and are now at 1024 4k pages, The app will run fine for a week then we will begin to see DB2 SQL error: SQLCODE: -954, SQLSTATE: 57011 indicating the transaction log is not able to accomodate the request.

Its not the size of the reports since they run fine after a recycle. I spoke with another DBA on this. He believe the problem was in a difference between ORACLE and DB2 in that the vendor code is crappy and not issuing commits on the selects. This is causing the references to not be cleaned up and is slowly accumulating as garbage in the heap.

I wanted to know if this is accurate as I thought only inserts and updates needed to have commits included. Is there any IBM documentation on this?

We are currently recycling on a weekly basis to alleviate the problem but I would like to have a good handle on the issue before going back to the vendor asking them to alter their code.

Advertisement

Answer

Any transaction needs to be properly terminated — why did you think that only applies to inserts and updates? Consider running transactionally a “select a from b where c > 12” and then “select a from b where c <= 12”; within a transaction the DB has to guarantee that every a gets returned exactly once either from the first or second select, not both (assuming c is never null;-). Without transactionality, some a’s might fall between the cracks or be returned twice if their corresponding c was changed by a different transaction, and that’s just not ACID!-)

So when you do not need separate SELECT queries to be transactional wrt each other, tell the DB! And the way you tell, is by terminating the transaction after each select (normally commit is what you use for the purpose, though I guess you could, indifferently, choose to use rollback here;-).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement