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 1uBrZc-007WgZ-Qm for pgsql-general@arkaria.postgresql.org; Mon, 05 May 2025 08:53:17 +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 1uBrZZ-002IXF-Ve for pgsql-general@arkaria.postgresql.org; Mon, 05 May 2025 08:53:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uBrZZ-002IX7-J8 for pgsql-general@lists.postgresql.org; Mon, 05 May 2025 08:53:13 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uBrZW-000F8f-0r for pgsql-general@postgresql.org; Mon, 05 May 2025 08:53:12 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-736c3e7b390so4609385b3a.2 for ; Mon, 05 May 2025 01:53:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kset.org; s=google; t=1746435186; x=1747039986; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=4nW1t8M/2pzIX3NEV3SOb7L7Po7Z0MY8HhN5UJRtdY8=; b=IvcU9MBkMrMGA7j4T2u3FG5HBvfgWw2iwIso1EClLEYRK9M2ho4FmSGTBIZpesryQA Y4hatiQdvJCNUWCLYtL5hqjXtWZzcyaoelqftzP4hkJfnb1cmCfF9LjmtO7opc+5Lb5G WGa0m4Ai110BUwBcV5vxhHS7tYBb7lrw5mQwh+4cQ2cZ5CgZRBd1IA6SdlovyjZG6/px e8kQmBrbV50CpAq1XtdOt3nTqLx0kugs654oZFddNr4IG57G2qbtcbaYpC8xFe0qVxow vEmajExA5VYxCYGMPIFRkNxtWNPdgf+dHpF0A0OhbbjiPLqMkvrIYCQnbh36v5Bj4q+3 RTOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746435186; x=1747039986; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=4nW1t8M/2pzIX3NEV3SOb7L7Po7Z0MY8HhN5UJRtdY8=; b=hYK8StcE7hXwsDfXgw+AB4d9jUnWd1WleHqUsNQI+masIqmhccVWzlHZ5bHdPYv2l+ O9biwDtbijbrW7u2a5Gh0hrwIsU15BjxX3oxkpJSyaR1NT9c4hH+1IFi52jSfloeHgm9 PuJ8vHEPYjdmxxkvyIr+RzYix6hlgZmJw0aj4sG+ZDL0VdRnTZ4uet/BLBFIixS172Z2 lt4v5WoBSES7Pj8pxHNid1b3RQ8r4QSyJG6l52QsKCS5T0tXI/byUpfnjfxIhqhtF564 wXifW8JCRYdPRR0aOnko37nQLxqpqMWDL/SG/rBMgKk2oJMZ0ZEes7AzNRGiA0Teg7xW r6JQ== X-Gm-Message-State: AOJu0YztKv2qUwXhG1ETX42KToW9iYWTKNn9V9LBm2varWBr9s/sYm/K BoIcHUiJfZpoo3+7iR5t/255g5fdQfGhN4xCW+0STXVuEUwexG6891dGGk7kQTczYYCcanrkSBo TM+LRoLQC/yoVXmB+xJkIDaIjr+Jc/x46yabp4mOI9kbnhgJuLLc= X-Gm-Gg: ASbGnct/aMOA+zWYlXjp5qy/JnFBwYrc85yNUDLCJupIix6JilmUc6vPghIZif/Zeyn /pogimsfNpW14JnA22ibUTajpyDZKq3x/vZxK1GB0AEOJBVCKEl7vvDctuVvCLBUPicgMPrZHoE kx3rqFvZNvOa36rREtTh7+Jw== X-Google-Smtp-Source: AGHT+IEJG+be90vIuhFc5Obu+XqE8elYAb9/9qI/fzAIk/7iTwndJWOBUeamFRFCBYA+L39tACAEAIgFWlaXJUJcDJY= X-Received: by 2002:a05:6a00:420c:b0:736:4e0a:7e82 with SMTP id d2e1a72fcca58-7406f0b0d75mr8532323b3a.10.1746435185604; Mon, 05 May 2025 01:53:05 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?Q?Mladen_Marinovi=C4=87?= Date: Mon, 5 May 2025 10:52:54 +0200 X-Gm-Features: ATxdqUExSJ2cN3eSbj8RdgokEUn9owJBCu-1NqFMGZV_3tJVbOw8KTnO8GOjvh0 Message-ID: Subject: Different execution plans in PG17 and pgBouncer... To: pgsql-general@postgresql.org Content-Type: multipart/alternative; boundary="000000000000dc89d406345fa0b4" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000dc89d406345fa0b4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, We recently migrated our production instances from PG11 to PG17. While doing so we upgraded our pgBouncer instances from 1.12 to 1.24. As everything worked on the test servers we pushed this to production a few weeks ago. We did not notice any problems until a few days ago (but the problems were here from the start). The main manifestation of the problems is a service that runs a fixed query to get a backlog of unprocessed data (limited to a 1000 rows). When testing the query using pgAdmin connected directly to the database we get a result in cca. 20 seconds. The same query runs for 2 hours when using pgBouncer to connect to the same database. The more interesting part is that when we issue an explain of the same query we get different plans. We did this a few seconds apart so there should be no difference in collected statistics. We ruled out prepared statements, as we suspected the generic plan might be the problem, but it is not. Is there any pgBouncer or PG17 parameter that might be the cause of this? Regards, Mladen Marinovi=C4=87 --000000000000dc89d406345fa0b4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

We recently migrated our= production instances from PG11 to PG17. While doing so we upgraded our pgB= ouncer instances from 1.12 to 1.24. As everything worked on the test server= s we pushed this to production a few weeks ago. We did not notice any probl= ems until a few days ago (but the problems were here from the start). The m= ain manifestation of the problems is a service that runs a fixed query to g= et a backlog of unprocessed data (limited to a 1000 rows). When testing the= query using pgAdmin connected directly to the database we get a result in = cca. 20 seconds. The same query runs for 2 hours when using pgBouncer to co= nnect to the same database.

The more interesting p= art is that when we issue an explain of the same query we get different pla= ns. We did this a few seconds apart so there should be no difference in col= lected statistics. We ruled out prepared statements, as we suspected the ge= neric plan might be the problem, but it is not. Is there any pgBouncer or P= G17 parameter that might be the cause of this?

Reg= ards,
Mladen Marinovi=C4=87
--000000000000dc89d406345fa0b4--