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 1t9ASY-008A8k-GB for pgsql-performance@arkaria.postgresql.org; Thu, 07 Nov 2024 21:54:33 +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 1t9ASV-0033DI-KV for pgsql-performance@arkaria.postgresql.org; Thu, 07 Nov 2024 21:54:32 +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 1t9ASV-0033DA-9e for pgsql-performance@lists.postgresql.org; Thu, 07 Nov 2024 21:54:31 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t9ASO-000k0r-8P for pgsql-performance@lists.postgresql.org; Thu, 07 Nov 2024 21:54:31 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-7b157c9ad12so104372885a.1 for ; Thu, 07 Nov 2024 13:54:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731016463; x=1731621263; darn=lists.postgresql.org; h=to:message-id:subject:date:mime-version:content-transfer-encoding :from:from:to:cc:subject:date:message-id:reply-to; bh=alf+X43ZD2UB1sztfF8RewVwdJHbdz/JESJsMVy9WwA=; b=JerH8lM4F9cCF2Ct1YTSvSkmJdkwGvEm+OM7JhxS13I8bM3br0YqV3AeJ41dFWZ1Zp Y/q1KCOinI7hrxC6p+7zOJryNhrRiRPBigT+5Zwyt3CMYJJWUsLB9lAZTKKJAFUzJZhL 1MJH2BVFzywo2x/2zOLN+vu+Pvo1doW1mOXO66Q3Pr0vvwiKKG7uUbLzNJU1prSQXqIS JXTpMSKrfXBUgEgMfX2l64u8aUK22YV6Qs1Cf4am2yrvykC4Qur4iFORmDv+cOfSq60o kEOpLx0cf2gT030tGPpPR7Wo63/nnIAhVskCxhcXng0eS2KW9A1EYCNfGpEFme8ADlxd n/7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731016463; x=1731621263; h=to:message-id:subject:date:mime-version:content-transfer-encoding :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=alf+X43ZD2UB1sztfF8RewVwdJHbdz/JESJsMVy9WwA=; b=ihEcjkkhpAO8s0kWzx/G+4SCenrEqWYEXA7Eezqcra7uTBhDOyMAteCTUjdkfjHoKd EIzZG9dL8ThqBJX9Xj5PU6HNOlzlOEBA2mosWOcOadeDKnJpmISGHKaLisuo2dslAZDl XQM2CNY2m/NmyqkHB92YGIHIG0IgGgtlK/xP5bOQ8FjBvju2C/0DLptZ0JSB1mu6QVUZ VtRu2VgfqXMj6FhP790UZ2ynQWLv6icvlaYR9T0RKyCCFmez9mzYBdOexS9ukoOGvi85 Cra2aH7FwYRTyrb2HAgtPgGYCT1R1qit5Oc8c2utckYijiVi7jtDSXBMbm8d/aNne0E9 l2MA== X-Gm-Message-State: AOJu0YzSouxJo7xl1m1PbMHzwjlpWHDAKyLUwfg001WYWEF2agbDxrn7 3sBgYQi0tUv1DksLnplnHxu4nADwGSJRUOjahA2/+3FN8zZJR75UgmWvxVeJ X-Google-Smtp-Source: AGHT+IFK2hcwuFFhaxU9cP0I/yAEkFGmcQwwnHI4yTHcxs4iVuIJ9qrATNaA/fwprnud4C5HoybuWg== X-Received: by 2002:a05:620a:44d3:b0:7a9:bd5b:eb61 with SMTP id af79cd13be357-7b331ebfaf3mr112534585a.27.1731016463174; Thu, 07 Nov 2024 13:54:23 -0800 (PST) Received: from ?IPv6:2601:14b:4100:214f:1dae:51df:a274:fb9e? ([2601:14b:4100:214f:1dae:51df:a274:fb9e]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b32ac8b35asm99336385a.69.2024.11.07.13.54.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Nov 2024 13:54:22 -0800 (PST) From: Ed Sabol Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.7\)) Date: Thu, 7 Nov 2024 16:54:21 -0500 Subject: Major performance degradation with joins in 15.8 or 15.7? Message-Id: <197E1EF0-BEDF-42C0-8508-56BC6E88AA35@gmail.com> To: pgsql-performance@lists.postgresql.org X-Mailer: Apple Mail (2.3445.9.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello! I have a database installation that goes back about 10 years. = It's using a hardware RAID consisting of enterprise-caliber spinning = drives. I upgraded the installation to PostgreSQL 15.8 a couple months = ago. Sometime after that, it was noticed that one of our application's = queries suffered major performance degradation. This query "suddenly" = went from taking 40-50 milliseconds to ~9 seconds, approximately 180-200 = times longer. Vacuuming and analyzing the table didn't help. The good news is that, after some research and experimentation, I was = able to fix this performance degradation by setting random_page_cost =3D = 2.0. We've always used the default values for seq_page_cost and = random_page_cost (1.0 and 4.0, respectively, I think?). A lot of the = advice I found online suggested these *_page_cost settings are too high? The table in question has ~350,000 rows and only 5 text columns. It = might have increased in size by about a thousand rows in the past couple = of months, but the table has not grown in size significantly. Did upgrading PostgreSQL to 15.8 cause this performance degradation? Did = the page costs calculation change in 15.8 (or 15.7)? The PostgreSQL = version is the only thing that has appreciably changed with this = database this whole year. Or do you think the size of the table just incrementally reached some = threshold that resulted in the optimizer changing its plan based on the = page costs? I was able to simplify the query in my testing down to something like = this: select * from atablename a inner join btablename b on a.somekey =3D = b.somekey and b.otherparam=3D'value' where b.otherparam2=3D'other = value'; All of the columns are text fields and indexed. Unfortunately, I don't = have the "EXPLAIN (ANALYZE, BUFFERS)" output from before I changed the = random_page_cost setting. It's no longer in my scollback buffer. Any theories or suggestions appreciated. Thanks, Ed