Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qe1c1-005WnY-Fd for psycopg@arkaria.postgresql.org; Wed, 06 Sep 2023 23:07:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qe1b2-00DjwY-2w for psycopg@arkaria.postgresql.org; Wed, 06 Sep 2023 23:06:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qe1b1-00Djvj-RK for psycopg@lists.postgresql.org; Wed, 06 Sep 2023 23:06:03 +0000 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qe1au-0038z1-77 for psycopg@postgresql.org; Wed, 06 Sep 2023 23:06:02 +0000 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-57124ee486dso197348eaf.3 for ; Wed, 06 Sep 2023 16:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694041555; x=1694646355; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Q9GfxPs3uVrAdskKuP4rtT5+qnLvPvj3uz7dorvav/8=; b=HDYTNvqOjR8hqr42BPSNre+dqDC74Zfc44Z3G0XXnyxIMPPyhyhtJhZA+FH2Ogsibd dWhrARkHbwCR1tB4Ou4tqH269DCpNnwG/HuVQHgM+1dNBwaRrpZf0K24M1UI1WFJnpe9 ZQuNlXdjYM6T+9Mzsm7QbAMiJ/Jjeq8g4MgHUIpZ/SvSbUr8SetHZA7HDsYDVVl8nwV/ La79pA21R5Oig8p/C9n39bfrxe10zctRebwHf94dJ6ksKr2JPozMCvPlwPXMWgdsmpe9 biHQC49IzdfJ2gFE1hsoyMTodateg9sIY3mgB+yV6jfp39T5e3fuXiFbYPOqWPVkP34L E9WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694041555; x=1694646355; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Q9GfxPs3uVrAdskKuP4rtT5+qnLvPvj3uz7dorvav/8=; b=QK4gEPzI0vp/F5rbfX5nU5T0WKVjsPZKgKVPtE1qeePNkl5GIvvmxvMuHJ/zswFDLW LAoNuYv7H4SVTGe2qLW2T0Reh8JpVs8Tgw0QgsDM6d+/Vy37BuZ41MuQL8aZGHXXFyHy cBoX/Ci281/Yru+dynABlw4qD45f3SpCoq/Zvz16LRm0oMMIUKRLxBPZkaVHYgiVIELD bZ+kPHSyat4weabPRjkaifttXLLb4tWmtKkeJ1stxc9ka+dR337waq1w6GphtQ5cdCqb JPTpNySWJ+GuIljrMu900BX1XuFPgF+jo9bawBMHcQlzTe9MZ0W7G9riJv5ZyFNRNPwr i09g== X-Gm-Message-State: AOJu0Yzj7w6lLXdmMvJh2KwkJ3O1VFd+2N0LYq1ArH2XdK/HsEWgxw20 MtfhYn+K8ddnFChsnyQwBE4eKAQStUh8JYzP/8AZFo/Ggw3zYw== X-Google-Smtp-Source: AGHT+IG0Qo2Anem3Z9Q3e1l41d9rmw9xzA0qkc5nDF37wfPZM/rXCtA33a8xKNZalgoIFYTIFIZudIHJT7dQ/ujXjCg= X-Received: by 2002:a4a:d202:0:b0:573:c037:e001 with SMTP id c2-20020a4ad202000000b00573c037e001mr15428229oos.4.1694041555346; Wed, 06 Sep 2023 16:05:55 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Daniele Varrazzo Date: Thu, 7 Sep 2023 00:05:43 +0100 Message-ID: Subject: Re: CPU usage for queries, psycopg 2 vs 3 To: David Raymond Cc: "psycopg@postgresql.org" Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 5 Sept 2023 at 18:52, David Raymond 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 . 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