Mysql - GROUP BY Avoid using tempoary

Posted by jwzk on Stack Overflow See other posts from Stack Overflow or by jwzk
Published on 2010-04-21T20:59:23Z Indexed on 2010/04/21 21:03 UTC
Read the original article Hit count: 150

Filed under:
|

The goal of this query is to get a total of unique records (by IP) per ref ID.

SELECT COUNT(DISTINCT ip), GROUP_CONCAT(ref.id)
FROM `sess` sess
JOIN `ref` USING(row_id)
WHERE sess.time BETWEEN '2010-04-21 00:00:00' AND '2010-04-21 23:59:59'
GROUP BY ref.id
ORDER BY sess.time DESC

The query works fine, but its using a temporary table. Any ideas?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about mysql-query