mysql slow log:
# Time: 2024-05-28T18:59:16.816636Z
# Query_time: 60.589167 Lock_time: 0.000001 Rows_sent: 20 Rows_examined: 15892065
SET timestamp=1716922696;
SELECT SQL_CALC_FOUND_ROWS DISTINCT meta_key FROM wp_postmeta WHERE 1=1 AND meta_key NOT IN('_edit_last','_edit_lock','_wp_page_template','_wp_attachment_metadata','_icl_translator_note','_alp_processed','_pingme','_encloseme','_icl_lang_duplicate_of','_wpml_media_duplicate','wpml_media_processed','_wpml_media_featured','_thumbnail_id') AND meta_key NOT LIKE '_%' LIMIT 20 OFFSET 0;
Symptoms:
The settings page failed to load, resulting in a 504 timeout error after 1 minute. The PHP slow log indicates a bottleneck at several database query functions, and the MySQL slow log shows a query taking over 60 seconds with a large number of rows examined.
Questions:
What could be causing the 504 timeout error when trying to load the WPML settings page?
How can I resolve the slow query performance as indicated in the MySQL slow log?