asyncpg icon indicating copy to clipboard operation
asyncpg copied to clipboard

cursor prefetch with bounded lag

Open ale-dd opened this issue 9 months ago • 0 comments

EDIT: nvm, looks like there's really no mechanism in the pgwire protocol that would support this behavior.

Would it at all be possible to support prefetching a batch of up to N rows via a cursor, as compared to waiting for exactly N rows to be available?

In other words, I would like to have a max_lag parameter similar to timeout, but with different semantics. If after max_lag at least 1 row, yet less than prefetch rows are available, do return the available rows.

Current api is:

cursor(query, *args, prefetch=None, timeout=None, record_class=None)

I would like it to be augmented as:

cursor(query, *args, prefetch=None, max_lag=None, timeout=None, record_class=None)

Is there any intrinsic limitation that would make this not worth the effort or simply there has been no interest for anything like that?

Thank you!

ale-dd avatar Apr 29 '24 11:04 ale-dd