ERPNext slow after months of transactions on v6

What have you done or considered to profile your bottleneck suspects?

This may help see if your performance problem is with slow db response
How to speed up your MySQL queries 300 times

You could add a timer to identify suspect functions - this discusses several tool options

To profile memory usage might help you get a handle on your problem - A module to profile peak memory usage of Python code - Stack Overflow

Once you collect response times and table size counts in a systematic way, you will have baseline measures to objectively gauge results or your attempts to improve performance.