当我使用此查询时,一切正常。5 结果在 0.3587 秒内。
SELECT `prod_combined`.`sku`, `prod_combined`.`titel`, `prod_combined`.`preis_vk`,
`prod_combined`.`link`
FROM `prod_combined`
WHERE
(
prod_combined.sku IN
(
SELECT
prod_combined.sku FROM
(
SELECT prod_combined.sku FROM prod_billiger
INNER JOIN
prod_combined ON prod_combined.sku = prod_billiger.sku
WHERE rangGesamt = 1
AND prod_combined.aktiv = 1
) q
JOIN prod_combined ON prod_combined.sku = q.sku)
)
AND (aktiv = 1)
LIMIT 0,5
但是当我使用这个查询时,它会运行大约 3 分钟。
SELECT `prod_combined`.`sku`, `prod_combined`.`titel`, `prod_combined`.`preis_vk`,
`prod_combined`.`link`
FROM `prod_combined`
WHERE
(
prod_combined.sku IN
(
SELECT
prod_combined.sku FROM
(
SELECT prod_combined.sku FROM prod_billiger
INNER JOIN
prod_combined ON prod_combined.sku = prod_billiger.sku
WHERE rangGesamt = 1
AND prod_combined.aktiv = 1
) q
JOIN prod_combined ON prod_combined.sku = q.sku)
)
AND (aktiv = 1)
我想要做什么:获取所有排名第一的产品(prod_billiger.rangGesamt)。我在“prod_billiger”表中得到这些信息。其他产品信息来自 prod_combined。
有没有办法加快速度?我需要过度考虑整个查询吗?
问候, 查奇2305