MagicStack / MagicStack/asyncpg
Large Object support
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 468
- PR merge metrics
- No merged PRs in 30d
Description
Are there any plans to have direct support for large objects for efficient streaming of data?
My use case: my webapp supports uploads of binary data files. These files are stored with TOAST (bytea) which is fine: these files are not directly downloaded via the app, and even if they were, we're talking 10s of MB, so I'm not worried about memory footprint for an individual record. HOWEVER, part of the requirements for this app is that all these files can be downloaded in a single zip file. This can be 100s of MBs. My plan: kickoff a background task that builds the zip file, then stores the zip file in PG as a large object. The question then is: providing an efficient download via my webapp (aiohttp).
I could stream it with a loop around, e.g.:
SELECT lo_get(data_oid, :offset, :chunksize) from zipstorage where id = :id
where chunksize might be 1MB and offset increases by 1MB with each iteration, stopping the iteration when the returned data is < 1MB.
Might there be a more direct, efficient way? E.g., as with psycopg2's lobject?
Other suggestions most welcome.
Thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no asyncpg files, tests, or entry points. Start by reviewing the proposed lo_get loop and the linked psycopg2 lobject reference, then determine the API scope and streaming behavior that would count as direct large-object support.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100