Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

cursor prefetch with bounded lag

Open
#1,149 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
postgresql, python

Research direction

Start by verifying the issue's stated pgwire limitation and reviewing the existing cursor API described in the report. No files or tests are named, and the requested behavior may not be implementable; completion would require a confirmed protocol-supported design and corresponding project scope.

Written by the indexing model from the issue text.

Description

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!

Dominant language
Python
Stars
8.1k
Forks
469
Avg merge
2d 20h
Merged PRs (30d)
9

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MagicStack/asyncpg

All issues in MagicStack/asyncpg

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.