REORG Avoidance

Modified on Mon, 30 Nov at 12:50 PM

Most Db2 shops decide which objects to reorganize from structural measures: how disorganized the data is, how much it has grown, how many rows have moved. Those measures are useful early warnings, but they do not say whether the applications are suffering. Many objects look disorganized and still perform perfectly well, so reorganizing them spends CPU, elapsed time and a maintenance window for nothing. TUC avoids those REORGs: it measures how efficiently Db2 really reads each object, reorganizes only where access performance has degraded or space is at risk, and checks afterwards that the REORG helped.

Key Benefits

Fewer REORGs — Objects that look disorganized but still perform well are left alone, and the CPU and elapsed time are saved.

The Right Ones Sooner — The effort goes to the objects whose access performance is really degrading, before the applications feel it.

Space Still Protected — Objects running out of space or near their maximum size are reorganized regardless, so availability is never traded for savings.

Proof, Not Assumption — Access performance is recorded before and after every REORG, so you can see whether each one paid off.

Almost No Overhead — The measurement comes from a low-cost Db2 statistics trace that writes very few records and can start with Db2.

Why Structural Measures Are Not Enough

A REORG puts the rows back in clustering order, restores free space and reclaims space that is no longer used. When the applications read the data in clustering order, that usually makes access faster. But not every object is read that way, and not every disorganized object is read often enough for its disorder to matter.

The usual REORG decision cannot tell those cases apart. It looks at the structure of the object, not at how the object is used, so it reorganizes some objects that gain nothing and reaches others only after their performance has already slipped. DBA teams spend real time trying to pick out the objects that truly need a REORG, and a calendar or a structural threshold alone cannot do it for them.


Measuring What the Applications Feel

When the data of an object loses its order, Db2 has to read more pages from disk to find the rows a query needs. Those reads are synchronous: the application waits for each one. A rise in synchronous I/O for the same amount of work is therefore the clearest sign that access performance has degraded.

TUC collects the getpage and synchronous I/O counters for every object from a Db2 statistics trace. The trace has a very low impact on the subsystem: Db2 writes very few SMF records, once in each statistics interval, and the trace can be started automatically whenever Db2 comes up. TUC accumulates the counters over time and turns them into one measure for each object: getpages per synchronous I/O. When that ratio falls, more of the work is going to disk, and the object is really degrading.

The chart shows the two cases. Object A was reorganized again and again, and its synchronous I/O never moved: the REORGs brought no benefit. Object B behaves differently: its synchronous I/O climbs as the data loses its order, and each REORG brings it back down. TUC tells the two apart and spends the REORG only on objects like B, ideally at the point where the climb starts, before the applications are affected.


How TUC Decides

Candidates First, Then Proof

The normal TUC policy rules still find the REORG candidates from the condition of each object. Access performance is then the second test. A candidate whose access performance has not degraded is excluded from the REORG automatically, and its REORG is saved. A candidate whose access performance has degraded is reorganized, with the priority its condition earns.


Space and Availability Always Come First

Some REORGs are not about performance at all. An object that is running out of space, or is approaching its maximum size, must be reorganized whatever its access performance, or it will fail. TUC never lets the performance test hold back a REORG that protects availability: those conditions override it.


Checking the Result

TUC keeps the access performance of every object from before its last REORG, from right after it, and from now. The effect of each REORG is visible instead of assumed. If an object was reorganized and its access performance did not improve, that is useful too: it shows that the object does not benefit from REORG, and TUC can leave it out of future REORGs that would not help.


What You Save

Every REORG avoided saves the CPU and elapsed time it would have taken, the work space it would have needed and the place it would have taken in the maintenance window. TUC keeps a running total of the processing time saved by REORGs it did not run, so the saving is a number you can show, not an estimate. The windows that are freed go to the objects that really need attention, so they are reorganized sooner.


Without and With TUC

TaskWithout TUCWith TUC
Choosing objectsBy structural thresholds or a calendar.By structure first, then by measured access performance.
Objects that do not benefitReorganized again and again.Left alone, and the CPU saved.
Objects that are degradingFound when the applications slow down.Found from rising synchronous I/O and reorganized in time.
Space and size limitsWatched separately.Always reorganized, whatever their access performance.
Was it worth it?Assumed.Measured before and after every REORG.
The savingUnknown.A running total of the processing time saved.

In short — TUC reorganizes an object when its access performance shows it needs it, or when space demands it, and not just because it looks disorganized. The REORGs that would bring nothing are skipped, the ones that matter happen sooner, and the result of each one is measured.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article