You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Background:
Currently the purge system groups the undo records based on table_id and then
it is distributed to different purge threads. This way all undo records
belonging to a single table is handled by the same purge thread. This grouping
is done to avoid contention b/w purge threads. Our documentation says this:
"If DML action is concentrated on a single table or a few tables, keep the
setting low so that the threads do not contend with each other for access to
the tables.".
Problem:
But, what if all the DMLs are happening on only one table. The grouping based
on table_id makes the distribution of work between purge threads lopsided. For
each purge batch, only one thread will be working on the undo records of the
single table. So the purge is slower and the purge lag is higher. Increasing
the number of purge threads will not help to purge faster.
Solution:
Auto tune solution.
Overall Idea:
1. Create only as many groups as there are purge threads.
2. Distributed the undo records based on table_id between these groups.
3. Check if the undo records are uniformly distributed.
4. If they are not uniformly distributed, redistribute.
Maximum (MAX) records per purge group:
1. Let total number of undo records in a purge batch be T.
2. Let M be the total number of purge threads.
3. Maximum number of records per group is (T + M)/M.
Minimum (MIN) records per purge group:
1. Let MAX be the the maximum number of records per purge group.
2. Let M be the total number of purge threads.
3. If MAX > M, then MIN = MAX - M.
4. If MAX =< M, then MIN = 0.
Redistribution:
1. Let i be the first group.
2. If the ith group has more records than it should, move extra records to the
next group.
3. If it is the last group, move extra records to the first group.
4. Increment i. And go to step 1.
5. Single pass is sufficient. But if extra records are moved from last to
first group, then one more pass is needed. In the 2nd pass, stop in the
first group having < MAX records.
What is uniform distribution in this context:
1. All groups have record count between MIN and MAX.
rb#26108 approved by Debarun Banerjee <[email protected]>
0 commit comments