rewrite LIMIT/OFFSET sql building, using max upper limit seems most portable in RDBMS's that support LIMIT/OFFSET