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 1uFZXs-00626J-QO for pgsql-bugs@arkaria.postgresql.org; Thu, 15 May 2025 14:26:49 +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 1uFZXr-00EwKg-Nl for pgsql-bugs@arkaria.postgresql.org; Thu, 15 May 2025 14:26:47 +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 1uFZXr-00EwKM-FJ for pgsql-bugs@lists.postgresql.org; Thu, 15 May 2025 14:26:47 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uFZXo-001vyO-2z for pgsql-bugs@lists.postgresql.org; Thu, 15 May 2025 14:26:46 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-43ce71582e9so8300725e9.1 for ; Thu, 15 May 2025 07:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747319204; x=1747924004; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=guH4HfmuIvV4b5dzYWtGhnsWMVLcBAxIpRTZsPP8bJE=; b=Ro6VA37nUMpUePTy8kfprjBVTtc9Ih2BFRmIkt5gWTZNKQRvWye7XUAWvX6DlDMtPv DRQRCcmGeinvBP7cbd80YcF8RpWc/VvsspF8NdPHWb30RQiJrQsrmfXQg+NfF9oXeq78 9yea1hKF19L/+Rpk41qiW4J1JkTWy93VsBg8ZP9IcVjKeCCSpIYUgcSaGnS0wT39wqJd zMdFh5lw0Nosawkq5FzcYGU8r2QgLPlOzxrPKzred+05//lQVUy07C+0SpODm4J7Ph36 cGUXfiHfjDyARMZNoZSWdhfOlwi/zhi0Qzoh3/kxhb5l3rQPDGkZEVxRfxl3ha1n2RvW xQlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747319204; x=1747924004; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=guH4HfmuIvV4b5dzYWtGhnsWMVLcBAxIpRTZsPP8bJE=; b=sWXTBtfHnPOhUed6QNW9vg88/334BWLCYIPNsnfQvv9DSr/2Pc2141d7Vo78AOSkwZ XISkE8hu8gdPvSk43UsUl44QZ28nnABOq5b6zrlA21PXeFSx9nXy7FXcdzrlCvCGnjsI LWOPQ/9mXsBbXs/hVW8czAgu22XigSkHftaOLhGxlup0dAr1YDa0Kq9Qa3IzuMItwLC8 FgvxOXwodzAHk4MPtZFtOqTwNIyGPDzU7JgPOcVcxlaVga2PuQq2fe9pO4z7eB/Sc8Ry RolVrnU/E8tTuB2eTrceE+YadKIhvZ40p3K+yXmSavtkhqPnGkL1lZNwEI0dkeCm5tYc J+hQ== X-Forwarded-Encrypted: i=1; AJvYcCWooSadJ+2FHNGB2zX+M1CrKTpJvuWWSctMxdHHqCg6bfBbruH6vaq6Rai0HhmUjhiO6EARch9wMkqN@lists.postgresql.org X-Gm-Message-State: AOJu0YzBzwEnmvg9x+TJQQXtYMp5hYqq7NVeY7idoaTZp5QsRs9ucFyQ fHHtfjxl2lE/HIsS28OzDeSTdgB9kgTS+KwF8R1vXTb3FSTIYilZ X-Gm-Gg: ASbGncvjLMTCzyBuVDZWroEaO3lykdi26gQceRvP+X22k+t5zTCfdrXNaGQr95K6KQa Q4oGk1q9YycVgKDciEDFGSJd9GZqj+46YbgojfuxlYO47UbpYIS9CLxvA+yIdWb/+7fsGcPFN01 ynheLWgfhuhueez5ctQOCBsSM8MSbR0pdjftbMqvlj6gS/cRLAhzY1B3iZWyK/LUMOwNL2EYyNN qNIEhTwFiwU8TWJ2VZIgff60EI3CKYTiv/GXcV58MkdEhrbT0hfzL1T1F567gqHxb3H32XpntTk cGcNVFg14yUbniArkQbdqz3G4po2Wb26wmdoEcVCQa7JTRnyQMuFwTPtn0MtMqg= X-Google-Smtp-Source: AGHT+IF5p6Y+lZkm9ERgugsEvZy0RWAI5TP4qOQVUpKfBjMcxcwSsq4vsYP5043Sb/2cG9LpsuX2sQ== X-Received: by 2002:a05:6000:4007:b0:3a1:f68b:60a8 with SMTP id ffacd0b85a97d-3a349699758mr7022628f8f.10.1747319203580; Thu, 15 May 2025 07:26:43 -0700 (PDT) Received: from [192.168.15.111] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-442f3951adcsm73125345e9.19.2025.05.15.07.26.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 May 2025 07:26:43 -0700 (PDT) Message-ID: <2a8243eb-a8e8-4c2d-9c46-7152782d84f8@gmail.com> Date: Thu, 15 May 2025 16:26:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Postgres: Queries are too slow after upgrading to PG17 from PG15 To: Sajith Prabhakar Shetty , "pgsql-bugs@lists.postgresql.org" References: Content-Language: en-US Cc: Peter Geoghegan From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 15/5/2025 07:33, Sajith Prabhakar Shetty wrote: > Hi, > > > Most of the queries got slower after upgrading our postgres from version > 15 to 17 using pg_upgrade. I reconfirmed that "vacuum full, analyze" > were all taken care. > > To debug, instead of upgrade, I installed two instances one with > postgres 15 and another postgres 17 with the same application dump restored. > > Now surprisingly one of the query i took from application which used to > execute in 2s in PG15, is now taking 1min+ in PG17. I also observed that > some of the operations involving DML operations slowed down too in PG17. > > Explain plan of the two queries almost same, all the joins and paths > used are exactly same. > > Could anybody please provide some insights here? Curious, the difference in Index Only Scan node: -> Index Scan using stream_file_pkey on stream_file sf (cost=1.63..1.86 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=598916) Index Cond: (id = sdo.stream_file_id) Filter: (component_id = ANY -> Index Only Scan using ui_stream_file_id_component on stream_file sf (cost=0.43..0.51 rows=1 width=8) (actual time=0.014..0.014 rows=1 loops=598916) Index Cond: ((id = sdo.stream_file_id) AND (component_id = ANY Each time the index scan is 2.5 times slower on PG17. But: PG 15: Buffers: shared hit=2338397 read=57267 I/O Timings: shared read=3384.286 PG 17: Buffers: shared hit=1909772 read=9933 I/O Timings: shared read=686.506 If I'm not mistaken, it seems like an insight. -- regards, Andrei Lepikhov