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:
SELECT
ship_id
FROM
((SELECT
DISTINCT l.meta_value AS ship_id
FROM
wp_posts a
JOIN
wp_postmeta f
ON ID = f.post_id
JOIN
wp_postmeta g
ON ID = g.post_id
JOIN
wp_postmeta h
ON ID = h.post_id
JOIN
wp_postmeta d
ON ID = d.post_id
JOIN
wp_postmeta i
ON ID = i.post_id
JOIN
wp_postmeta l
ON ID = l.post_id
WHERE
post_type = 'product'
AND f.meta_key = 'first_start_date'
AND g.meta_key = 'last_start_date'
AND h.meta_key = 'product_group'
AND h.meta_value = 'cruises'
AND d.meta_key = 'destinationregion'
AND i.meta_key = 'destinationarea'
AND 'South America' IN (
d.meta_value, i.meta_value
)
AND (
(
STR_TO_DATE(f.meta_value, '%b %e, %Y') BETWEEN CONCAT('2016', '-01-01') AND CONCAT('2016' + 1, '-01-01')
)
)
AND l.meta_key = 'cruiseship'
ORDER BY
l.meta_value ASC)
UNION
DISTINCT (SELECT
DISTINCT l.meta_value AS ship_id
FROM
wp_posts a
JOIN
wp_postmeta f
ON ID = f.post_id
JOIN
wp_postmeta g
ON ID = g.post_id
JOIN
wp_postmeta h
ON ID = h.post_id
JOIN
wp_postmeta d
ON ID = d.post_id
JOIN
wp_postmeta i
ON ID = i.post_id
JOIN
wp_postmeta l
ON ID = l.post_id
WHERE
post_type = 'product'
AND f.meta_key = 'first_start_date'
AND g.meta_key = 'last_start_date'
AND h.meta_key = 'product_group'
AND h.meta_value = 'cruises'
AND d.meta_key = 'destinationregion'
AND i.meta_key = 'destinationarea'
AND 'South America' IN (d.meta_value, i.meta_value)
AND ((CONCAT('2016', '01-01') BETWEEN STR_TO_DATE(f.meta_value, '%b %e, %Y') AND STR_TO_DATE(g.meta_value, '%b %e, %Y')))
AND l.meta_key = 'cruiseship'
ORDER BY
l.meta_value ASC)
) AS union1
ORDER BY
union1.ship_id ASC