What maintenance are you currently performing? Server Cleanup Wizard (SCW), declining superseded updates, running the SQL Indexing script, etc.?
https://www.ajtek.ca/wsus/how-to-setup-manage-and-maintain-wsus-part-8-wsus-server-maintenance/
There's not one 'script' that will fix it all as each part of the maintenance requires something different.