Hi Alain,
I’m Vicente’s colleague. We identified the root cause of the problem as a large accumulation of InvalidChildCounts entries that needed to be deleted in cascade. After adding an index on InvalidChildCounts(id), the issue was resolved.
We also observed a similar pattern with GlobalIntegersChanges during the execution of UpdateStatistics. When this function isn’t run periodically, the accumulated entries can grow to a point where the first execution causes the database to crash due to resource exhaustion.
Based on our experience, I would recommend the following improvements for future versions:
- Add an index on
InvalidChildCounts(id)to speed up deletions. - Introduce a
LIMITin theDELETEquery withinUpdateSingleStatisticto processGlobalIntegersChangesin smaller, manageable batches.
For context, in our case:
UpdateStatisticstook around 12 hours before we had to manually terminate it to free up database CPU.DeleteResourcewas taking between 3 and 15 minutes per execution.
After applying the above optimizations, both operations now complete in just a few seconds.
Best regards,
Rafik