Re: CPU usage for queries, psycopg 2 vs 3

Поиск
Список
Период
Сортировка
Искать
От
Adrian Klaver
Тема
Re: CPU usage for queries, psycopg 2 vs 3
Дата
Msg-id
d372707b-6758-8696-3f50-cd4fe4501b66@aklaver.com
Ответ на
Список
Дерево обсуждения
CPU usage for queries, psycopg 2 vs 3 David Raymond <David.Raymond@tomtom.com>
Re: CPU usage for queries, psycopg 2 vs 3 Daniele Varrazzo <daniele.varrazzo@gmail.com>
Re: CPU usage for queries, psycopg 2 vs 3 Daniele Varrazzo <daniele.varrazzo@gmail.com>
RE: CPU usage for queries, psycopg 2 vs 3 David Raymond <David.Raymond@tomtom.com>
Re: CPU usage for queries, psycopg 2 vs 3 Daniele Varrazzo <daniele.varrazzo@gmail.com>
Re: CPU usage for queries, psycopg 2 vs 3 Daniele Varrazzo <daniele.varrazzo@gmail.com>
RE: CPU usage for queries, psycopg 2 vs 3 David Raymond <David.Raymond@tomtom.com>
Re: CPU usage for queries, psycopg 2 vs 3 Daniele Varrazzo <daniele.varrazzo@gmail.com>
Re: CPU usage for queries, psycopg 2 vs 3 Adrian Klaver <adrian.klaver@aklaver.com>

On 9/5/23 10:51 AM, David Raymond wrote:
> I've noticed that CPU usage for queries seems to have drastically increased going from psycopg2 to psycopg3.
>
> In psycopg2 a connection would sit quietly while waiting for the results, using next to no CPU.
> In psycopg it looks like the threads are using their core at full power, continuously checking for the result as fast as possible, and never sleeping or relaxing.
>
> See below for a simple example script. During the psycopg2 part while the 8 threads are waiting on results my processor usage sits at the normal idling 2-3%. But in the psycopg3 part, while the 8 threads are waiting on results my processor usage jumps up to 62-63% or so.
>
> Is there a setting or configuration I'm missing?

Take a look at this:

https://github.com/psycopg/psycopg/issues/448

It seems to be related.


> This is on Windows, where I install with "pip install psycopg2-binary" and "pip install psycopg[binary]"
> Current versions shown by pip list:
> psycopg            3.1.10    (This gets installed even when telling it to install psycopg[binary])
> psycopg-binary     3.1.10
> psycopg2-binary    2.9.7
>
> And their reported .__version__
> psycopg.__version__: 3.1.10
> psycopg2.__version__: 2.9.7 (dt dec pq3 ext lo64)
>
> I've got several scripts where I open up multiple connections to multiple servers and run a number of queries on them, where 98% of my machine's time should be just relaxing and waiting for the server to finish the next 1 to 15 minute long query. I don't need to continue the very microsecond the query completes. Is there anything I can do to bring CPU usage back down with psycopg (3) ?



>
> Thank you,
>
>


В списке psycopg по дате отправления
От: David Raymond
Дата:
От: Daniele Varrazzo
Дата:
FAQ