SELECT
COUNT(DISTINCT IF(user_id = 1, user_session, user_id)) usercount,
CONCAT(LEFT(user_lastaction, 8), '000000') the_day
FROM stats_users
GROUP BY the_day
ORDER BY
anzahl DESC,
the_day DESC
LIMIT 1
the table stats_memberzones stores a history uf users's activities
user_id is a refernce to my user table, user_session hiólds the session-id and user_lastaction holds the timestamp that clicked something or hit refresh or...
i want to know the day with the highes count of visitors (guests and members) and how much people this have been
the members are identified by their user_id which is > 1
guests will have a user_id of 1 so i have to distinguish them via user_session
any ideas how to improve this?
does mysql use indices i set on user_id and user_session even if i use them in SELECT only and not in WHERE clause?
tia 🙂