不適切な検索クエリがサイトをクラッシュさせています。すべてのサブカテゴリをカウントし、それらを合計してメインカテゴリの合計を取得した人。ページングの場合、Next、Last、Pages、およびクエリは JOIN/ INNER JOIN (そのページのすべての製品) で記述されます。あまりにも多くのステップを作成しているため、タイムアウトするまですべてが遅くなります。ヘルプ!
クエリの要約:
SELECT COUNT(DISTINCT node.nid) AS cnt FROM
content_type_product cp
LEFT JOIN node node ON node.nid = cp.nid
LEFT JOIN uc_products uc_products ON node.nid = uc_products.nid
LEFT JOIN users users ON users.uid = node.uid
LEFT JOIN files ON files.fid = cp.field_product_image_1_value
LEFT JOIN content_type_product_tags ct ON ct.field_product_product_id_value = cp.nid
WHERE
(
node.status <> N
)
AND
(
ct.field_product_tag_id_value = N
)
AND
(
cp.field_deleted_value <> N
)
AND
(
cp.field_stock_level_value > N
)
AND EXISTS
(
SELECT scp.nid FROM content_type_store scp
LEFT JOIN node snode ON snode.nid = scp.nid
LEFT JOIN users susers ON susers.uid = snode.uid
WHERE susers.name = users.name
AND scp.field_shop_activated_value = 'S'
AND scp.field_shop_suspended_value = 'S')
ORDER BY cp.field_product_last_changed_value DESC;
クエリのサンプル:
SELECT count(Distinct node.nid) as cnt
FROM content_type_product cp
LEFT JOIN node node ON node.nid = cp.nid
LEFT JOIN uc_products uc_products ON node.nid = uc_products.nid
LEFT JOIN users users ON users.uid = node.uid
LEFT JOIN files ON files.fid = cp.field_product_image_1_value
LEFT JOIN content_type_product_tags ct ON ct.field_product_product_id_value = cp.nid
WHERE
(
node.status <> 0
)
AND
(
ct.field_product_tag_id_value = 478
)
AND
(
cp.field_deleted_value <> 1
)
AND
(
cp.field_stock_level_value > 0
)
AND EXISTS
(
SELECT scp.nid FROM content_type_store scp
LEFT JOIN node snode on snode.nid = scp.nid
LEFT JOIN users susers on susers.uid = snode.uid
WHERE susers.name = users.name
AND scp.field_shop_activated_value = '1'
AND scp.field_shop_suspended_value = '0'
)
ORDER BY cp.field_product_last_changed_value DESC