In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `wp_postmeta` ADD INDEX `wp_postmeta_idx_meta_key_post_id` (`meta_key`,`post_id`);
ALTER TABLE `wp_posts` ADD INDEX `wp_posts_idx_post_type_post_statu_id` (`post_type`,`post_status`,`ID`);
ALTER TABLE `wp_posts` ADD INDEX `wp_posts_idx_id` (`ID`);
SELECT
SQL_CALC_FOUND_ROWS wp_posts.ID
FROM
wp_posts
WHERE
(
1 = 1
AND wp_posts.post_type = 'product'
AND (
wp_posts.post_status = 'publish'
)
AND (
(
1 = 1
AND 1 = 1
)
AND (
1 = 1
AND 1 = 1
)
)
)
AND (
EXISTS (
SELECT
1
FROM
wp_postmeta
INNER JOIN
wp_postmeta AS mt1
WHERE
(
(
(
(
(
wp_posts.ID = wp_postmeta.post_id
)
AND (
wp_postmeta.meta_key = '_visibility'
)
)
AND (
CAST(wp_postmeta.meta_value AS CHAR) IN (
'visible', 'catalog'
)
)
)
AND (
wp_posts.ID = mt1.post_id
)
)
AND (
mt1.meta_key = '_stock_status'
)
)
AND (
CAST(mt1.meta_value AS CHAR) = 'instock'
)
)
)
GROUP BY
wp_posts.ID
ORDER BY
wp_posts.menu_order,
wp_posts.post_title ASC LIMIT 0,
10