What is a better way to keep "user online"?
The fastest and easiest to scale query is the query you don't run.


Move your session state to a cache tier like memcached or Redis.
Update the cached value on every user interaction, not the database value.
Persist to the database via a background task that periodically scans the cache for updates.