我有一个我认为不够优化的 SQL 查询。我计时了,有时需要1.5秒才能完成,这似乎有点高,不是吗?
无论如何,这是查询:
SELECT id, link, feed, category, description, title, GROUP_CONCAT( tag ) as t, published
FROM items
LEFT JOIN tags ON items.id = tags.item_id
WHERE id NOT IN (
SELECT item_id
FROM tags, sinunim
WHERE tag = name
AND op = '1'
AND user = '$user_cookie'
) AND id NOT IN (
SELECT id
FROM sinunim
WHERE id <> 0
AND user = '$user_cookie'
) AND id NOT IN (
SELECT i.id
FROM sinunim s, items i
WHERE s.type = 'category'
AND s.name = i.category
AND s.op = '1'
AND s.user = '$user_cookie'
) AND id NOT IN (
SELECT i.id
FROM `sinunim` s, items i
WHERE s.name = i.feed
AND s.op = '1'
AND s.user = '$user_cookie'
)
GROUP BY items.title
ORDER BY items.published DESC
LIMIT 0 , 50