Re: CPU usage for queries, psycopg 2 vs 3

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: David Raymond <David(dot)Raymond(at)tomtom(dot)com>
Cc: "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>
Subject: Re: CPU usage for queries, psycopg 2 vs 3
Date: 2023-09-06 23:05:43
Message-ID: CA+mi_8Z98u3Gq-3JrAbWRW7ar9hhPAO5umze==xgpEHdxdcPKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Tue, 5 Sept 2023 at 18:52, David Raymond <David(dot)Raymond(at)tomtom(dot)com> wrote:
>
> I've noticed that CPU usage for queries seems to have drastically increased going from psycopg2 to psycopg3.

Hello David,

thank you for the report. No, this is not expected: psycopg 3 uses I/O
completion functions to wait idle for results from the server, so it
shouldn't consume more cpu than psycopg2. I will investigate (but on
Linux, I don't have a Windows machine handy to test with).

There was a change in the waiting function in psycopg 3.1.5, related
to <https://github.com/psycopg/psycopg/issues/414>. I wonder if it was
a regression with that change? Could you please be so kind as to
repeat your tests with psycopg 3.1.4?

Also, did you try only to connect on localhost? Are you able to run
the same test with a server running on a different network location?

Thank you very much

-- Daniele

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message David Raymond 2023-09-07 12:17:40 RE: CPU usage for queries, psycopg 2 vs 3
Previous Message Adrian Klaver 2023-09-05 18:22:52 Re: CPU usage for queries, psycopg 2 vs 3