1

I am using wordpress and building a dashboard. There are a lot of complex MYSQL queries that I am running in order to return results from the DB. I am returning these as custom short codes in wordpress, with each query as its own function. That seems to be causing the page to take A LONG time to load >15seconds each time. Is there a better way to do this that would be faster? My customer shortcodes .php file is about 1500 lines long with about 50 calculations. Not all are used on the same dashboard tab, but obviously it is running each in order to get through the ones it needs.

  • Is there a way you could segment out the calculation and then load them conditionally based on whether or not they're needed? Also, it could be beneficial to load these via AJAX in increments, so that the page loads quickly and then the calculations fire one by one via AJAX. – Tony Djukic Nov 29 '20 at 3:41
  • @tonydjukic . Thanks. They arent horribly hard calcs but unfortunately they are needed to display all at teh same time since it is sales data that all shows at once. Is there a better way somehow that I might not know about? – Mikey Nov 29 '20 at 6:06
  • You can display them all at the same time... ...eventually... ...what I'm suggesting is segmenting their execution and loading sequentially. If you break each calc down it's probably nano seconds to execute, but when you lump them all together and make the page load wait until it's all done before it shows anything at all you can SEE the slow process. What I'm suggesting is that you separate the admin screen load and the calculation functions so that the admin loads and then javascript fires an AJAX query to run the calculations. You show a little load icon while it does this. – Tony Djukic Nov 29 '20 at 15:39
  • It's kinda hard to answer with a greater degree of specificity without actually seeing what's happening. But to simplify - detach the calculations functionality for the dashboard widget from the admin page load screen by letting the admin load fully first, and then running a separate AJAX load for the dashboard widget. – Tony Djukic Nov 29 '20 at 15:41
  • Additional information request. RAM size, # cores, any SSD or NVME devices on MySQL Host server? Post on pastebin.com and share the links. From your SSH login root, Text results of: B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; E) STATUS; F) SHOW ENGINE INNODB STATUS; G) SELECT name, count FROM information_schema.innodb_metrics ORDER BY name; for server workload tuning analysis to provide suggestions. – Wilson Hauck Dec 13 '20 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.