MagicStack / MagicStack/asyncpg
Difference between bulk update with FROM VALUES and without it?
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 8.1k
- 分支
- 468
- PR 合併指標
- 30 天內沒有已合併 PR
描述
```python3
await conn.executemany(
"""
UPDATE user SET login=$2, name=$3, age=$4, sex=$5
WHERE id=$1
""",
users,
)
```
```python3
await conn.executemany(
"""
UPDATE user SET login=actual_user.login, name=actual_user.name, age=actual_user.age, sex=actual_user.sex
FROM (VALUES ($1, $2, $3, $4, $5)) AS actual_user (id, login, name, age::integer, sex::integer)
WHERE user.id=actual_user.id
""",
users,
)
```
The first is cleaner. But I worry about performance. I know the second is performed as one request. But the first is the same?
Is there any reason to use the second way?
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 asyncpg 的 executemany 入口點和 PostgreSQL 的 UPDATE ... FROM VALUES 語意開始,同時比較 SQL 範例及其請求行為。完成標準是清楚地記錄並說明這些方法在效能或用途上是否有所不同,以及第二種形式何時有用。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- postgresql, python
- 領域
- databases
- Issue 類型
- 文件
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 35/100