Fork me on GitHub
#hugsql
<
2021-03-30
>
mafcocinco20:03:52

Does hugsql support lazy sequence of values via a query of against a Postgres backend?

seancorfield20:03:04

@mafcocinco Getting “lazy sequences” from a database is very problematic because of resource management issues (the connection needs to be open while the sequence is being processed but needs to be closed when you’re done with it — and the sequence has no way of knowing that).

seancorfield20:03:33

There are ways to stream large result sets from a database, so that the data is read “lazily” from the DB, but to do so you need to eagerly reduce the result set — again so the connection management can do the right thing.

seancorfield20:03:40

Both next.jdbc and the older clojure.java.jdbc libraries provide a way to reduce over streaming results. HugSQL can use both of these libraries but I don’t think it exposes any way to leverage the reduce/streaming option, just the full eager processing option. So you’d have to drop down to the underlying library to do that.