Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issues regarding psycopg2 vs psycopg3 benchmark #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion _python/pgbench_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ def psycopg_copy(conn, query, args):
def psycopg2_executemany(conn, query, args):
cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
cur.executemany(query, args)
conn.commit()
return len(args)

def psycopg_executemany(conn, query, args):
with conn.cursor() as cur:
cur.executemany(query, args)
conn.commit()
return len(args)


Expand Down Expand Up @@ -183,6 +185,7 @@ async def asyncpg_executemany(conn, query, args):
async def async_psycopg_executemany(conn, query, args):
async with conn.cursor() as cur:
await cur.executemany(query, args)
await conn.commit()
return len(args)


Expand Down Expand Up @@ -247,7 +250,8 @@ def sync_worker(executor, eargs, start, duration, timeout):
max_latency = req_time
if req_time < min_latency:
min_latency = req_time
latency_stats[req_time] += 1
if req_time <= 200000:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silently truncating latencies like that does not seem right. Why is this change necessary?

latency_stats[req_time] += 1
queries += 1

return queries, rows, latency_stats, min_latency, max_latency
Expand Down
4 changes: 2 additions & 2 deletions _python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
aiopg==1.4.0
asyncpg==0.27.0
py-postgresql==1.3.0
psycopg2-binary==2.9.6
psycopg2-binary==2.9.9
numpy>=1.25.0
uvloop~=0.17.0
psycopg[binary]==3.1.9
psycopg[binary]==3.1.18
2 changes: 2 additions & 0 deletions pgbench
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ BENCHMARKS = [
'golang-libpq',
'golang-pgx',
'python-aiopg',
'python-psycopg2',
'python-psycopg3',
'python-aiopg-tuples',
'python-asyncpg',
'python-psycopg3-async',
Expand Down