SELECT count(*) FROM messages GROUP BY uid