Fix a problem with an SQL that coule be too large

When getting content-ids for last-modified-date computation
the SQL query could sometimes be to long for Oracle database.
This fix limits the length to the latest contents if the maximum
number is exceeded.