If you want the latest by user, you can cheat a bit and use the fact that
the id's are incrementing, thus ordering by the id
is about the same as ordering by the date field. I know it can be inexact
in some corner cases, but it's a good approximation, and
very useful in practice :
SELECT user_id, max(note_id) FROM notes GROUP by user_id;
So :
SELECT * FROM notes WHERE id IN (SELECT max(note_id) FROM notes GROUP by
user_id) ;
Can postgres use the index on these max() clauses now ?