Language: Deutsch · English
Process large tables efficiently – read in chunks and replace OFFSET with keyset pagination.
HOW-TO DEVELOPER UPDATED: JUL 2026 APPLIES TO NUCLOS 4.2026.X
On this page
Two basic rules to process very large tables (millions of records) efficiently.
final long CHUNKSIZE = 5000;
long lastID = 0L;
Map<UID, FieldMeta<?>> mpFields = metaProvider.getAllEntityFieldsByEntity(entity);
DbQueryBuilder builder = dataBaseHelper.getDbAccess().getQueryBuilder();
for (;;) {
DbCondition cond = builder.plainCondition("t.INTID > " + lastID);
CollectableSearchCondition csc = new CollectableDbCondition(cond);
CollectableSearchExpression cse = new CollectableSearchExpression(csc);
Collection<EntityObjectVO<Long>> lstEOs = entityObjectFacade.getEntityObjectsChunk(entity, mpFields.values(), null, cse, 0L, CHUNKSIZE - 1);
if (lstEOs.isEmpty()) {
return;
}
for (EntityObjectVO<Long> eo : lstEOs) {
....
lastID = eo.getPrimaryKey();
}
}