select *
from (
select *,
row_number() over(
partition by user_id
order by createdat desc, rating desc
) as rn
from t1
where
status = 1 and some_field not in (?, ?, ..., ?)
and user_id in (1,2,3)
) s
where rn <= 10
order by user_id, rn
Window functions:
http://www.postgresql.org/docs/current/static/functions-window.html
http://www.postgresql.org/docs/current/static/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS
http://www.postgresql.org/docs/current/static/tutorial-window.html