Liebe Community,
ich bespiele aktuell einen Shop mit 170.000 Variantenartikeln (bei 260 Basisartikeln).
Wenn ich nun eine Kategorie anklicke dauert das Laden der Seite beim ersten Mal an die 30 Sekunden, nach dem Cachen an die 10 Sekunden.
Der Profiler zeigt das ca. 90% der Queryzeit durch 2 Queries von Shopware verursacht werden.
Nach genauerem Betrachten sind hier sehr viele nested loops vorhanden. (Siehe Screenshot)
Nummer 1 (3.09782004356 Ausführungszeit):
SELECT
MIN(listing_price.cheapest_price)
FROM
s_articles product
INNER JOIN s_articles_details variant ON variant.id = product.main_detail_id
AND variant.active = 1
AND product.active = 1
INNER JOIN s_articles_categories_ro productCategory4 ON productCategory4.articleID = product.id
AND productCategory4.categoryID IN (: category4)
LEFT JOIN s_articles_avoid_customergroups avoidCustomerGroup ON avoidCustomerGroup.articleID = product.id
AND avoidCustomerGroup.customerGroupId IN (
: customerGroupIds38ba0f9d2195aa1ed719d712288c9fae
)
INNER JOIN (
SELECT
prices.*,
MIN(
ROUND(
prices.price * (
(
100 - IFNULL(priceGroup.discount, 0)
) / 100
) * (
(
(
CASE tax.id WHEN 1 THEN 19 WHEN 4 THEN 7 END
) + 100
) / 100
) * 1,
2
)
) as cheapest_price
FROM
s_articles product
INNER JOIN s_core_tax tax ON tax.id = product.taxID
INNER JOIN (
SELECT
`id`,
`pricegroup`,
`from`,
`to`,
`articleID`,
`articledetailsID`,
`price`,
`pseudoprice`,
`baseprice`,
`percent`
FROM
s_articles_prices defaultPrice
WHERE
defaultPrice.pricegroup = : fallbackCustomerGroup
) prices ON product.id = prices.articleID
INNER JOIN s_articles_details availableVariant ON availableVariant.articleID = product.id
AND availableVariant.active = 1
LEFT JOIN s_core_pricegroups_discounts priceGroup ON priceGroup.groupID = product.pricegroupID
AND priceGroup.discountstart = 1
AND priceGroup.customergroupID = : priceGroupCustomerGroup
AND product.pricegroupActive = 1
WHERE
(
prices.articledetailsID = availableVariant.id
)
AND (prices.from = 1)
GROUP BY
product.id
) listing_price ON listing_price.articleID = product.id
INNER JOIN s_articles_attributes productAttribute ON productAttribute.articledetailsID = variant.id
WHERE
avoidCustomerGroup.articleID IS NULL
**Nummer 2 (**2.73407816887 Ausführungszeit) :
SELECT
MIN(listing_price.cheapest_price)
FROM
s_articles product
INNER JOIN s_articles_details variant ON variant.id = product.main_detail_id
AND variant.active = 1
AND product.active = 1
INNER JOIN s_articles_categories_ro productCategory4 ON productCategory4.articleID = product.id
AND productCategory4.categoryID IN (: category4)
LEFT JOIN s_articles_avoid_customergroups avoidCustomerGroup ON avoidCustomerGroup.articleID = product.id
AND avoidCustomerGroup.customerGroupId IN (
: customerGroupIds38ba0f9d2195aa1ed719d712288c9fae
)
INNER JOIN (
SELECT
prices.*,
MIN(
ROUND(
prices.price * (
(
100 - IFNULL(priceGroup.discount, 0)
) / 100
) * (
(
(
CASE tax.id WHEN 1 THEN 19 WHEN 4 THEN 7 END
) + 100
) / 100
) * 1,
2
)
) as cheapest_price
FROM
s_articles product
INNER JOIN s_core_tax tax ON tax.id = product.taxID
INNER JOIN (
SELECT
`id`,
`pricegroup`,
`from`,
`to`,
`articleID`,
`articledetailsID`,
`price`,
`pseudoprice`,
`baseprice`,
`percent`
FROM
s_articles_prices defaultPrice
WHERE
defaultPrice.pricegroup = : fallbackCustomerGroup
) prices ON product.id = prices.articleID
INNER JOIN s_articles_details availableVariant ON availableVariant.articleID = product.id
AND availableVariant.active = 1
LEFT JOIN s_core_pricegroups_discounts priceGroup ON priceGroup.groupID = product.pricegroupID
AND priceGroup.discountstart = 1
AND priceGroup.customergroupID = : priceGroupCustomerGroup
AND product.pricegroupActive = 1
WHERE
(
prices.articledetailsID = availableVariant.id
)
AND (prices.from = 1)
GROUP BY
product.id
) listing_price ON listing_price.articleID = product.id
INNER JOIN s_articles_attributes productAttribute ON productAttribute.articledetailsID = variant.id
WHERE
avoidCustomerGroup.articleID IS NULL
GROUP BY
product.id
ORDER BY
listing_price.cheapest_price DESC
LIMIT
1 OFFSET 0
Die Zeit der Datenbank:
Manchmal geht es sogar an fast 99% der gesamten SQL Zeit.
Hatte hier jemand auch mal das Problem?
Liebe Grüße
Adrian