Automattic / Cron-Control

A fresh take on running WordPress's cron system, allowing parallel processing
https://wordpress.org/plugins/wp-cron-control/
GNU General Public License v2.0
121 stars 21 forks source link

Improve performance of is_installed check #374

Closed noahtallen closed 9 months ago

noahtallen commented 9 months ago

We noticed this query performing poorly in some cases, especially when the DB is under load. See this post for more context: p4IuY0-4S6-p2#comment-16728. This PR includes two improvements:

  1. Use an information_schema query for table existence check, rather than SHOW TABLES LIKE .... Running this query by itself on the mysql replica takes under 10ms, whereas the show tables query is more like 700+ms. (Not the best benchmark, but does verify that it should be better.
  2. Just in case, also cache false is_installed values. While it shouldn't happen that frequently since Cron Control is active by default, this query otherwise executes a few times every page load, so it should be a nice little improvement.

is_installed should execute (at least) on admin pageviews, so you can verify the main changes there.