Fix #2168, #1676: Bad query in who is online uses too much memory