Попробуйте вместо этого -
добавить индексы:
ALTER TABLE `wp_postmeta` ADD INDEX `wp_postmeta_idx_key_id_value` (`meta_key`,`post_id`,`meta_value`);
ALTER TABLE `wp_posts` ADD INDEX `wp_posts_idx_type_parent_title_id` (`post_type`,`post_parent`,`post_title`,`ID`);
ALTER TABLE `wp_posts` ADD INDEX `wp_posts_idx_content_parent_title_id` (`post_content`,`post_parent`,`post_title`,`ID`);
ALTER TABLE `wp_posts` ADD INDEX `wp_posts_idx_excerpt_parent_title_id` (`post_excerpt`,`post_parent`,`post_title`,`ID`);
ALTER TABLE `wp_posts` ADD INDEX `wp_posts_idx_title_parent_id` (`post_title`,`post_parent`,`ID`);
Запрос на выполнение:
SELECT
*
FROM
((SELECT
posts.ID AS product_id,
posts.post_parent AS parent_id,
posts.post_title
FROM
wp_posts posts
WHERE
(
(
1 = 1
AND 1 = 1
)
)
AND posts.post_type IN (
'product', 'product_variation'
)
AND EXISTS (
SELECT
*
FROM
wp_postmeta postmeta
WHERE
posts.ID = postmeta.post_id
AND postmeta.meta_key = '_sku'
AND postmeta.meta_value LIKE '%INVMCB278A2W%'
)
ORDER BY
posts.post_parent ASC,
posts.post_title ASC)
UNION
DISTINCT (SELECT
DISTINCT posts.ID AS product_id,
posts.post_parent AS parent_id,
posts.post_title
FROM
wp_posts posts
WHERE
(posts.post_content LIKE '%INVMCB278A2W%')
AND posts.post_type IN ('product', 'product_variation')
ORDER BY
posts.post_parent ASC,
posts.post_title ASC)
UNION
DISTINCT (SELECT
DISTINCT posts.ID AS product_id,
posts.post_parent AS parent_id,
posts.post_title
FROM
wp_posts posts
WHERE
(posts.post_excerpt LIKE '%INVMCB278A2W%')
AND posts.post_type IN ('product', 'product_variation')
ORDER BY
posts.post_parent ASC,
posts.post_title ASC)
UNION
DISTINCT (SELECT
DISTINCT posts.ID AS product_id,
posts.post_parent AS parent_id,
posts.post_title
FROM
wp_posts posts
WHERE
(posts.post_title LIKE '%INVMCB278A2W%')
AND posts.post_type IN ('product', 'product_variation')
ORDER BY
posts.post_parent ASC,
posts.post_title ASC)
) AS union1
ORDER BY
union1.post_parent ASC,
union1.post_title ASC