Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Regression in copy records performance between 0.30.0 and 0.31.0 #1327

Copy link
Copy link

Description

@elenlee
Issue body actions

When run on different versions (0.30.0 vs 0.31.0), the following script reproduces the issue and consistently shows a performance regression of approximately 22%:

import asyncio
import asyncpg
import time

COUNT = 5_000

async def run():
    conn = await asyncpg.connect("postgresql://user:password@localhost/postgres")

    await conn.execute("CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, username TEXT, email TEXT, age INT)")

    RECORDS = [("John Doe", "john.doe@example.com", 42)] * 10_000

    start = time.perf_counter()
    for _ in range(COUNT):
        await conn.copy_records_to_table("users",  records=RECORDS,  columns=["username", "email", "age"])
    end = time.perf_counter()

    await conn.close()

    return end - start


if __name__ == "__main__":
    total = asyncio.run(run())
    print(f"Total time: {total:.5f} seconds")
    print(f"Average time per loop: {total / COUNT:.8f} seconds")
(common) [e.lee@OC0000842]$ pip install asyncpg==0.30.0
(common) [e.lee@OC0000842]$ python -m example
Total time: 89.15468 seconds
Average time per loop: 0.01783094 seconds

(common) [e.lee@OC0000842]$ pip install asyncpg==0.31.0
(common) [e.lee@OC0000842]$ python -m example
Total time: 108.57080 seconds
Average time per loop: 0.02171416 seconds
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.