Sql patch to improve statistics gathering performance when using pending stats
Hi MOSC community,
I would like to share a sql patch to improve statistics gathering performance when using pending stats. I've been raising a SR for this issue, and the MOS DocID: 2998260.1 was finally published recently. Since there was no specific sql patch mentioned, I thought it would be useful to share here in the MOSC. If you are using pending stats in 19c with more than 1,000 tables (partitions) and find CPU usage is high during maintenance window, this could be related.
The sql patch will affect the two delete statements. The patch has to be executed in each pdb where you find the issue. I created a test case to reproduce the issue. As far as I tested in BaseDB service (19.20) in OCI, the elapsed time of statistics gathering improved 88 min to 21 min. Please find the complete test case and the result in the attached file.