Hi Aris,
Actually we used OrientDB under out Support System for client where we have chat room, one per client. The best way we found to model this is by creating one class/cluster per chat. Example:
Chat_clent10
Chat_clent11
Chat_clent12
...
Since chat message are naturally ordered by date, and since OrientDB assigns incremental RIDs to records, you don't need an index at all. You can execute this query when the user logs in:
select from Chat_clent11 order by @rid desc limit 20
Note the bold part: when use "order by @rid desc", OrientDB open an iterator that starts from the end to the beginning. We called Inverse iterator. it's super fast and speed is not affected by database size. What about loading records of the previous page?
select from Chat_clent11 where @rid < #13:2342 order by @rid desc limit 20
Supposing your last @rid was #13:2342 (read from the previous query).
Hope it helps.
Lvc@