Are you talking about applying the setMaxResult / setFirstResult on database?
There is a flaw, but I'm not sure we want to fix this flaw as the optimization is worthwhile.
When you order by nullable columns, some databases returns null columns first some do return null columns last. Applying an ordering on heterogenous shards could lead to an undefined behavior.
Aside from that, you can apply the max limit as firstResult + maxResult in DB without applying the firstResult, this will optimize DB accesses. You can then apply the firstResult in memory.