Open stormgrass opened 4 years ago
Good catch on the compound key! I'll see if I add this by default or at least add it to the docs somehwere.
Unrelated: Your wp_podlove_modules_logging_logtable table is huge and can safely be truncated. You may even consider deactivating the "Logging" module, which is responsible for logging to the database. That may help with your database load a little as it decreases the amount of writes.
As far as I can see all the remaining slow queries are from the analytics index screen (admin.php?page=podlove_analytics
), specifically the "global analytics for last 30 days" section. Those may be tricky to optimize as you would need a dedicated compound key per query (accessed_at
+ source
for example) but you also don't want too many indices. The more indices you define on wp_podlove_downloadintentclean
, the more expensive writes become.
At the moment I don't see an easy/obvious performance fix. If that's an option for you, I could add a switch to disable that whole "global analytics for last 30 days" section, so those slow queries would never run.
Thank you for your reply! I suspected that solving the slow-query issue would be a bit tricky. But, I've now turned off the logging module, let's see if that makes a dent.
As for the 30 day section: would turning that off have any impact on tracking in general? If we can still keep tracking as usual, I'd be very happy to turn off that section in return for a more stable server.
would turning that off have any impact on tracking in general?
No, none at all. I can add a feature switch in the next release.
That would be fantastic, thank you!
MySQL slow queries make our MySQL server crash (plus workaround for one slow query)
Expected behavior
A stable MySQL server, even during high loads
Actual behavior
We've been dealing with our MySQL server crashing during high loads for a while now and have finally identified the problem (probably). After setting up a log for slow queries, we identified two types of queries that put quite the load on our server.
The first type looked like this:
We examined the relevant table structure, and saw that there's no index for "hours_since_release":
General Information:
We then created this compound index on media_file_id and hours_since_release:
mysql> create index idx_hrs_release on wp_podlove_downloadintentclean(media_file_id, hours_since_release); Query OK, 0 rows affected (35,46 sec) Records: 0 Duplicates: 0 Warnings: 0
Updated query plan:
Outcome:
Performance after index is dramatically faster, at 0.01 seconds:
So this sorted the first type of slow query. But there's other queries too, which tend to take ages and bog down our server when the load is high. Here's an example:
Any ideas how to speed up those queries would be vastly appreciated!
System information (see
Podlove > Support
menu)Website https://www.zeitsprung.fm PHP Version 7.3.17-1+ubuntu16.04.1+deb.sury.org+1 WordPress Version 5.5.1 WordPress Theme Twenty Twenty v1.3 Active Plugins
disable_functions pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, permalinks ok (/%postname%/) podlove_permalinks ok podcast_settings ok web_player ok podlove_cache on assets
0 errors 0 notices Nice, Everything looks fine!