Apparently the slowlog is working now. Do you know what fixed that issue?
Meanwhile, this has morphed into query tuning...
What is #1 for? Why is it run so often? It returns an average of 156K rows examined (the whole table?), but only 665 rows returned. 665 is a lot of rows; do you really need them all? Could more filtering be done in the SQL?
It sounds like there is no INDEX(autoload)
-- add it; it should speed up the query considerably.
#1
SELECT option_name, option_value
FROM wp_options
WHERE autoload = 'S'
What are you doing with the thousands of rows from the following? And you are preforming them thousands of times?
#2
SELECT st.value AS tra, s.value AS org, s.domain_name_context_md5 AS ctx
FROM wp_icl_strings s
LEFT JOIN wp_icl_string_translations st ON s.id=st.string_id
AND st.status=N
AND st.language='S'
AND s.language!='S'
#3
SELECT slug, taxonomy
FROM wp_posts
INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id =
wp_term_taxonomy.term_taxonomy_id )
INNER JOIN wp_terms ON (wp_term_taxonomy.term_id = wp_terms.term_id )
WHERE wp_posts.ID IN ("S","S","S","S","S","S","S","S","S",...)
ORDER BY wp_terms.name ASC
#4
SELECT t.element_id, tax.term_id, tax.taxonomy
FROM wp_icl_translations t
JOIN wp_term_taxonomy tax ON t.element_id = tax.term_taxonomy_id
AND t.element_type = CONCAT('S', tax.taxonomy)
JOIN wp_terms terms ON terms.term_id = tax.term_id
WHERE tax.term_id != tax.term_taxonomy_id
Why the LEFT
in #2? That probably prevents starting with st
, which might be more selective with INDEX(language, status)
.
In #3: wp_terms might benefit from INDEX(name)
.
In #4: The schema design led to the clumsy CONCAT('S', tax.taxonomy)
; can that be rectified? That is, can t.element_type
and tax.taxonomy
look the same -- either both with the prefix or both without? Or maybe the prefix is a separate column?
If you would like to discuss any of these further, please provide SHOW CREATE TABLE
and EXPLAIN SELECT ...
.