이 쿼리MySQL은) (
SELECT
itemID,
locationParentID,
locationID,
categoryParentID,
categoryID,
itemTitle,
itemDetails,
itemAttributes,
itemPictures,
itemFeatured,
itemSpotlight,
itemAdded
FROM items
WHERE items.siteID IN('".$cfg['site']['siteShares']."')
AND EXISTS(SELECT 1 FROM sites_locations sl WHERE items.locationID = sl.locationID AND siteID = '".$cfg['site']['siteID']."' LIMIT 1)
AND EXISTS(SELECT 1 FROM sites_categories sc WHERE items.categoryID = sc.categoryID AND siteID = '".$cfg['site']['siteID']."' LIMIT 1)
AND itemStatus = '1'
AND itemAdded > '".$cfg['timestamp']."'
작품 정말 느린 존재하지만 그것은 육초
이여기에 무엇을 내가 그것을 빨리 될 것 같은데요로 내가 JOIN
을 사용하여 할 수
의 개까지 소요 나는 JOIN
으로 시도했지만 sites_location
테이블에있는 위치를 가진 항목 대신 모든 결과를 반환합니다.
SELECT
itemID,
locationParentID,
categoryParentID,
categoryID,
itemTitle,
itemDetails,
itemAttributes,
itemPictures,
itemFeatured,
itemSpotlight,
itemAdded
FROM items LEFT JOIN sites_locations
ON items.locationID = sites_locations.locationID
AND sites_locations.siteID = items.siteID
WHERE items.siteID IN('1,2') AND itemStatus = '1'
AND itemAdded > '1356048000' ORDER BY itemID DESC LIMIT 15
이유가 전혀 존재 사용 하는가를 얻을 수없는 이유의 차이입니다
? 일반 크로스 조인 (심지어 natrual)처럼 여기에 것들을 정렬 것 같습니다 – Najzero
당신의 인덱스는 무엇입니까? – h2ooooooo
items table primary = itemID; sites_locations 테이블 기본 자동 AND 위치 ID는 관계입니다. –