What we have:
3 MySQL DB tables: user, text, friend
user: username, password, email, etc.
text: username, text, date, etc.
friend: username, friend_username, etc.
Task:
Write an algorithm (in Java) to show 10 latest texts from your friends.
Ultimate target is to have running time within O(n log n).
DB tables can be modified (added new ones) as required.
Data volume: 200 000 users, ~50 text per user.
I would appreciate any ideas, examples, points, etc. Thank you!
(Not a homework. Pure problem, looking for performance improvement)