MagicStack / MagicStack/asyncpg

Large Object support

Đang mở
#826 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
8.1k
Fork
468
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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!

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Issue không nêu tên tệp, bài kiểm thử hoặc entry point nào của asyncpg. Hãy bắt đầu bằng việc xem xét vòng lặp lo_get được đề xuất và tài liệu tham chiếu psycopg2 lobject được liên kết, sau đó xác định phạm vi API và hành vi streaming nào sẽ được tính là hỗ trợ trực tiếp cho large object.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
postgresql, python
Lĩnh vực
database
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.