I am using MySQL (MyISAM) 5.0.41 and I have this query:
SELECT `x`.`items`.id, `x`.`items`.name, COUNT(*) AS count
FROM `x`.`items` INNER JOIN `x`.`user_items`
ON `x`.`items`.id = `x`.`user_items`.item_id
GROUP BY name HAVING count > 2 ORDER BY count DESC
I have about 36,000 users, 175,000 user_items and 60,000 items that are constantly being added. So this query is slowing down a bit ...
Is it better:
- Enter
countin the field itemsand update periodically (say, every time the user adds an item) - or run a query like this (slow).
Or is there any SQL that populates the count field for me?
thank
source
share