Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Feature request: Support for asynchronous command processing

オープン
#1,141 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
postgresql, python
領域
databases

調査の方向性

まず、issue にリンクされている libpq の非同期コマンド処理のドキュメントを確認し、次に conn.fetch 周辺の asyncpg 接続 API と、コルーチンを gather したときの現在の InterfaceError の挙動を調べてください。提案されている非パイプライン動作を extended query protocol と比較し、要求されている API と同期セマンティクスが実現可能かどうかを判断してください。issue にはファイルやテストのエントリーポイントがありません。

索引モデルが issue の本文から書いたものです。

説明

libpq has support for something called asynchronous command processing (https://www.postgresql.org/docs/current/libpq-async.html).

Thea idea is fairly simple: you can queue up multiple queries on one connection without waiting for the previous result and then wait for all the results at the end. This avoids waiting for network round trips between queries, which at least in theory should have the same performance benefits as running multiple queries with one network round trip.

It would be useful if asyncpg could support the same concept. The Python API should be fairly straightforward. You just start multiple coroutines with queries and then await all of them together at the end. Something like this:

q1 = conn.fetch('SELECT $1', 1)
q2 = conn.fetch('SELECT $1', 2)
q3 = conn.fetch('SELECT $1', 3)
results = await asyncio.gather(q1, q2, q3) # (currently this raises InterfaceError)

This could have significant performance benefits in situations where you make multiple fast independent queries, especially if there is a large network round-trip delay.

AFAIK implementing this is definitely possible in theory. In practice, the complexity depends a lot on how the internals of asyncpg are structured, which I am not familiar with.

EDIT: This request is motivated by the same goal as https://github.com/MagicStack/asyncpg/issues/839, but my proposal is to specifically use asynchronous command processing without pipelining. If my understanding of the extended query protocol is correct, it should be possible to issue multiple queries without waiting for results between them but with a sync point after each query, which helps avoid the complex error handling rules of pipeline mode. (If my understanding of extended query protocol is not correct, this may be impossible. Feel free to correct me.)

主要言語
Python
スター
8.1k
フォーク
469
平均マージ
2日 20時間
マージ済み PR(30日)
9

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

MagicStack/asyncpg のほかの issue

MagicStack/asyncpg の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。