26.0.x: higher client CPU per call for `fetchone()` / `execute()` compared to 4.0.2
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 32/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- python
- 领域
- databases, performance
调研方向
Start by running the included repro_overhead.py against 4.0.2 and 26.0.1 in both thin and thick modes to confirm the fetchone() and execute() CPU gap while fetchmany() stays flat. Then compare how the two versions handle the per-row fetch path, since that is where the regression appears. Done means the per-call overhead is traced to a specific change and the numbers come back within a few percent of 4.0.2 in both modes.
由索引模型根据 Issue 内容生成。
描述
- What versions are you using?
- python-oracledb: 26.0.1, compared with 4.0.2 (stock PyPI wheels)
- Oracle Database: 12.1.0.2.0
- Oracle Client (Thick mode): 19.18.0.0.0
- Python: 3.11.13
- platform.platform: Linux-6.18.54.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
- sys.maxsize > 2**32: True
- Is it an error or a hang or a crash?
Neither: performance regression.
- What error(s) or behavior you are seeing?
fetchone() and execute() use more client CPU in 26.0.1 than in 4.0.2, in both Thin and Thick modes. fetchmany() is unchanged.
Client CPU time measured with the script below (seconds, average of two runs, each run being the median of 5):
| Operation | Mode | 4.0.2 | 26.0.1 | Change |
|---|---|---|---|---|
fetchone() loop, 50k rows |
Thin | 0.182 | 0.237 | +31 % |
fetchone() loop, 50k rows |
Thick | 0.199 | 0.303 | +52 % |
2000 × (execute() + fetchone()) |
Thin | 0.383 | 0.445 | +16 % |
2000 × (execute() + fetchone()) |
Thick | 0.397 | 0.477 | +20 % |
fetchmany() scan, 50k rows |
Thin | 0.169 | 0.179 | +6 % |
fetchmany() scan, 50k rows |
Thick | 0.190 | 0.190 | 0 % |
- Does your application call init_oracle_client()?
Both modes were measured (Thin and Thick).
- Include a runnable Python script that shows the problem.
No schema needed. Run once with each oracledb version:
ORA_USER=... ORA_PASSWORD=... ORA_DSN=host:port/service python repro_overhead.py thin
ORA_USER=... ORA_PASSWORD=... ORA_DSN=host:port/service python repro_overhead.py thick
import os
import statistics
import sys
import time
import oracledb
MODE = sys.argv[1] if len(sys.argv) > 1 else "thin"
ROWS = 50_000
N_EXEC = 2_000
REPEAT = 5
if MODE == "thick":
oracledb.init_oracle_client()
oracledb.defaults.arraysize = 100
oracledb.defaults.prefetchrows = 101
conn = oracledb.connect(user=os.environ["ORA_USER"], password=os.environ["ORA_PASSWORD"],
dsn=os.environ["ORA_DSN"])
SCAN = f"""select level, level / 7, date '2026-01-01' + mod(level, 365), 'row_' || level
from dual connect by level <= {ROWS}"""
ONE = "select :k, 'x' from dual"
def s1_fetchmany():
with conn.cursor() as cur:
cur.execute(SCAN)
while cur.fetchmany():
pass
def s2_execute_fetchone():
with conn.cursor() as cur:
for k in range(N_EXEC):
cur.execute(ONE, k=k)
cur.fetchone()
def s3_fetchone():
with conn.cursor() as cur:
cur.execute(SCAN)
while cur.fetchone() is not None:
pass
def cpu(fn):
fn() # warm-up
samples = []
for _ in range(REPEAT):
c0 = time.process_time()
fn()
samples.append(time.process_time() - c0)
return statistics.median(samples)
print("oracledb", oracledb.__version__, MODE)
print(f"fetchmany() scan of {ROWS} rows : CPU {cpu(s1_fetchmany):.3f} s")
print(f"{N_EXEC} x (execute() + fetchone()) : CPU {cpu(s2_execute_fetchone):.3f} s")
print(f"fetchone() loop over {ROWS} rows : CPU {cpu(s3_fetchone):.3f} s")
- 主要语言
- Python
- 星标
- 456
- 派生
- 119
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
oracle/python-oracledb 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 15/100
oracle/python-oracledb#629 ·
-
bug
难度 4/5 3-5 天 新手友好度 22/100
oracle/python-oracledb#628 ·
-
Thin mode: ORA-01483 for string binds of 2731-8191 bytes on a database with the UTF8 character set未关闭
难度 4/5 3-5 天 新手友好度 45/100
oracle/python-oracledb#627 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 75/100
oracle/python-oracledb#626 ·
-
bug
难度 4/5 3-5 天 新手友好度 48/100
oracle/python-oracledb#625 ·
查看 oracle/python-oracledb 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 78/100
elviskahoro/sdk-python-attio#144 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
RenyiELBO raises TypeError when model has no sample sites可能已有人在做 @alibb007 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复