skip to Main Content

How to tell PostgreSQL via JDBC that I'm not going to fetch every row of the query result (i.e. how to stream the head of a result set efficiently)?

Quite frequently, I'd like to retrieve only the first N rows from a query, but I don't know in advance what N will be. For example: try(var stream = sql.selectFrom(JOB) .where(JOB.EXECUTE_AFTER.le(clock.instant())) .orderBy(JOB.PRIORITY.asc()) .forUpdate() .skipLocked() .fetchSize(100) .fetchLazy()) { // Now run…

VIEW QUESTION
Back To Top
Search