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 1syrov-002iS4-18 for pgsql-admin@arkaria.postgresql.org; Thu, 10 Oct 2024 11:59:06 +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 1syrou-00Glui-5C for pgsql-admin@arkaria.postgresql.org; Thu, 10 Oct 2024 11:59:04 +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 1syrot-00GluZ-Ll for pgsql-admin@lists.postgresql.org; Thu, 10 Oct 2024 11:59:04 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1syror-000CGN-AD for pgsql-admin@lists.postgresql.org; Thu, 10 Oct 2024 11:59:02 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-53988c54ec8so1025477e87.0 for ; Thu, 10 Oct 2024 04:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728561539; x=1729166339; darn=lists.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=q+uQvrhsXbk/sGrGZHOGJfqMO0NQMNS8iP+4GqX1RTA=; b=jUncGbzIB/k/ygXLa9jut0XGek/mcOACnuLI60kSSXdQx3wWqhvivFVwfCrKzJETvw bhvMhpOzXSpz/F/n7PNG8OPMjR6YNNiEB2CzwhyBqLNSe2IBcrwWmXZLRsk6NBIaIoGo KD+ncK71AM01bqIUKiQ1J9ydsXB7jbFz6ZxqqUppTBn/mfuYy9nXAjGH5KV/DJqjoDPH 6bxSfR8BC4c1ABwzIdPu5HIaHIWqyqKbCuGdU1flPSrZoakZm79gIcShuk6pwrkzT1BJ KhNWAXxhZp0txV+7uU2vPf2mqMvKIUr+DbwmAoDEnyi/Dd9TejopgSvsALoXXOZdTmeS oZ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728561539; x=1729166339; 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=q+uQvrhsXbk/sGrGZHOGJfqMO0NQMNS8iP+4GqX1RTA=; b=DPTPGycyHAq+dQnWBuWtNgoo8ecFv2yyNqYAUR86vJimw2x9DpT/TqKVoHBARNxHkX ENco2hGroeO3kFYpt9hnilSrf7uLw5Wk28nAe5G0RmW2ta4IunDPxdqUAjgmXsi75Uxq xyCBJRjvEAF5d1Gx42jaPUcYVMW9gA3l/Cpp8b1AEg1voKSvyEYOZAD/KsRCeWG41PCF bOqrsut02NDNMnyTSswzkWpB81iWpcJM7BNYn5RuZ4dHwuvlhUT3WYPJwEw2C7S+QnxM McxKix3BRSIPsgk+5XHZiqhsRAG9Z3FCuXVxVx5g2Wwp5qDfT8CjhqMS1kwTwafXob/e DNJw== X-Gm-Message-State: AOJu0YwA/GYoiW7ujiv2BwQ/SqubLfLsWytLBUx6oGxragTtQGVNOP56 ck6HvUucag5fpkJTjR/w45lYMLnWV4ywUBXq+pdc5fpD5jxBqsYnT75tNQwMmXhh/olHhxS4cGp BUIi6QKF/XrX+5wUSrt/OmQtT+mg= X-Google-Smtp-Source: AGHT+IHCVQtl/kDpzuOSdbyEIN/g177IrOGKzGxYjdlGIusqMFbcB8SBGrdA9AShvWNrlG02sUJ1S/NYYqgUm90L3s8= X-Received: by 2002:a05:6512:1110:b0:52e:9b2f:c313 with SMTP id 2adb3069b0e04-539c48975f6mr4199587e87.22.1728561538795; Thu, 10 Oct 2024 04:58:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Miroslav Mladenov Ivanov Date: Thu, 10 Oct 2024 14:58:47 +0300 Message-ID: Subject: Re: Google Cloud PostgreSQL Upgrade v11 to 15 To: SOzcn Cc: Pgsql-admin Content-Type: multipart/alternative; boundary="0000000000007e15d206241e180e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000007e15d206241e180e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello , Maybe you should try pg_hint_plan to control the execution plan for your problematic queries. You should check for execution plans for queries before the upgrade and try to generate similar plans to these . On Thu, Oct 10, 2024 at 1:07=E2=80=AFPM SOzcn = wrote: > Hello All, > I hope everything is well with you. I have some issues after upgrading th= e > GCP. > > We performed an upgrade on Google Cloud PostgreSQL from version 11 to 15. > Initially, we executed this in our test environment, and there were no > major issues observed. > > However, we unfortunately encountered a performance issue with one > particular query after the upgrade of Production. Below is my detailed > analysis, and I would appreciate your comments on the matter. > > When we carried out the upgrade in the Production environment, we faced > several major problems. First and foremost, there was a relentless disk > issue and high CPU consumption. We realized that the root cause of these > two problems was the activation of the log_duration parameter, which was > generating thousands of logs per second, and we resolved it. > > We also discovered that the execution plans had changed after the upgrade= , > which was expected. Since it was performing a table scan, retrieving a > total of 200 records through paging took minutes. By setting the > random_page_cost parameter to 4, I managed to direct it towards an Index > Scan. As a result, the 200 records were fetched within 3-5 seconds. > > At this point, the query is running consistently on both version 11 and > version 15, taking 3-5 seconds to retrieve 200 records. However, while > version 11 processed 20,000 records in 15-20 seconds, version 15 is takin= g > 1.5-2 minutes for the same amount. > > The query contains many joins and subqueries. Based on this, I maximized > the values of the work_mem parameter and ran tests, but no improvement wa= s > observed. > > In my research on similar cases, I found that some cases reported success > by disabling the jit parameter, but it didn=E2=80=99t help in my case. > > I also tried standard analyze and index maintenance, including rebuilding > the indexes. Additionally, I took the problematic database to my local > environment and conducted tests on versions 15 and 16. However, there was > no change in performance. > > After analyzing the query, I tried certain indexing methods on the > identified costly parts, but they didn=E2=80=99t help. Additionally, I te= sted by > disabling the subqueries and using temporary tables, but that also did no= t > lead to a solution. > > I look forward to your comments on this matter. > --0000000000007e15d206241e180e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello ,

Maybe you should try pg_hint_pl= an to control the execution plan for your problematic queries. You should c= heck for execution plans for queries before the upgrade and try to generate= similar plans to these .

On Thu, Oct 10, 2024 at 1:07=E2=80=AFPM SOzc= n <selahattinozcnma@gmail.= com> wrote:
Hello All,
I hope everything is well with you. = I have some issues after upgrading the GCP.

We performed an upgrade = on Google Cloud PostgreSQL from version 11 to 15. Initially, we executed th= is in our test environment, and there were no major issues observed.
However, we unfortunately encountered a performance issue with one particu= lar query after the upgrade of Production. Below is my detailed analysis, a= nd I would appreciate your comments on the matter.

When we carried o= ut the upgrade in the Production environment, we faced several major proble= ms. First and foremost, there was a relentless disk issue and high CPU cons= umption. We realized that the root cause of these two problems was the acti= vation of the log_duration parameter, which was generating thousands of log= s per second, and we resolved it.

We also discovered that the execut= ion plans had changed after the upgrade, which was expected. Since it was p= erforming a table scan, retrieving a total of 200 records through paging to= ok minutes. By setting the random_page_cost parameter to 4, I managed to di= rect it towards an Index Scan. As a result, the 200 records were fetched wi= thin 3-5 seconds.

At this point, the query is running consistently o= n both version 11 and version 15, taking 3-5 seconds to retrieve 200 record= s. However, while version 11 processed 20,000 records in 15-20 seconds, ver= sion 15 is taking 1.5-2 minutes for the same amount.

The query conta= ins many joins and subqueries. Based on this, I maximized the values of the= work_mem parameter and ran tests, but no improvement was observed.

= In my research on similar cases, I found that some cases reported success b= y disabling the jit parameter, but it didn=E2=80=99t help in my case.
I also tried standard analyze and index maintenance, including rebuilding= the indexes. Additionally, I took the problematic database to my local env= ironment and conducted tests on versions 15 and 16. However, there was no c= hange in performance.

After analyzing the query, I tried certain ind= exing methods on the identified costly parts, but they didn=E2=80=99t help.= Additionally, I tested by disabling the subqueries and using temporary tab= les, but that also did not lead to a solution.

I look forward to you= r comments on this matter.
--0000000000007e15d206241e180e--