asStream

abstract fun asStream(fetchSize: Int = 100): StreamingTerminalMethods

Switches the builder to streaming mode, optimal for large datasets.

Requires an active transaction. Must be called inside a DataAccess.transaction { } block — otherwise PostgreSQL will ignore fetchSize and load all rows into RAM.

dataAccess.transaction { tx ->
tx.select("*").from("census_records")
.where("year = @year")
.asStream(fetchSize = 500)
.forEachRow<CensusRecord>("year" to 14) { record ->
processCensusEntry(record)
}
}

Return

New builder instance with streaming terminal methods.

Parameters

fetchSize

Number of rows fetched from the database in one batch.