Posted By


dimkalinux on 06/01/13

Tagged


Statistics


Viewed 48 times
Favorited by 0 user(s)

numberOfPurchase


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. --- Запрос выполянется более 1 минуты и (почему-то) неправильно считает numberOfPurchase
  2. --- Оптимизируйте запрос (без изменения индексов)
  3. --- Hint: тормозит ORDER BY numberOfPurchase
  4.  
  5. SELECT DISTINCT cache.item_id, COUNT(oi.id) AS numberOfPurchase
  6. FROM cache_item_country_language cache
  7. LEFT JOIN OwnedItem oi ON oi.item_id = cache.item_id
  8. WHERE cache.language_id = 'eng'
  9. AND cache.item_type = 'book'
  10. GROUP BY cache.item_id ORDER BY numberOfPurchase DESC LIMIT 5;
  11.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.