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 1u1s6J-009TIZ-Am for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 19:25:43 +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 1u1s6H-0033rE-Nu for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 19:25:42 +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 1u1s6H-0033r1-97 for pgsql-general@lists.postgresql.org; Mon, 07 Apr 2025 19:25:41 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u1s6E-003yf3-28 for pgsql-general@postgresql.org; Mon, 07 Apr 2025 19:25:41 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-43cf257158fso33448075e9.2 for ; Mon, 07 Apr 2025 12:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornfield-me-uk.20230601.gappssmtp.com; s=20230601; t=1744053937; x=1744658737; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=DRmFhT8i6kTUqApCwPJqicSN+Wbwg6i48TOhF6PGR8g=; b=Ar6hvZx5OxUJqz/SD5vvpzrA+rglLvoKeabWgxUmF0Lg8ObG9SKhFi0Dt/jZ/b8A5Q c9XvCBRJdG/RB2UJMSgsL23RwGOzIzApqUZG9aQDaFT/AR69gy44IbwBGA92E60lRLnE wRSjjSi5i7zEIRb+AfFZskFupQB6BY6eR30SqAp85R1j/37/xCy6MNgTMS5V0l3BjBBd W9ErlXYr8/Z/g4iLimr0RZYEduqL7SZOGYyRu+lPhlcQpaMWs4N2Ip+N3W4ax3xjsUUd yKI7N5ysZBeDPHvHRrH/tlonq/zf5PgOQFrhHS18dAy/+bSthbB0AJTxwdZNHag4J8kB DppQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744053937; x=1744658737; h=content-transfer-encoding:in-reply-to:from: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=DRmFhT8i6kTUqApCwPJqicSN+Wbwg6i48TOhF6PGR8g=; b=B+1qjaMuPtO/xuk1zqqlro9rgczZaXS1JyesvVOu6E6cj4KUu9njS6oV+CGwUW1GVX EKSkdrbpni/Ho3vbmWSpzTwUavf7ktRKhwS8vtzfvVNsR7s42SP9mYS/GHcck/LpMzl8 gEEArCoCbr0T1312rClvvXQWih3jz2QDyzxkYf9TlzaIHkq0sdBIAtwUssoPo7uIM8Mw 8fda3TXQBVcnDZDvUxgJoskkNbhqfIegntIA+C7o0CXHgIgjuPKYM0lSyHjD1iS9wMCU saToohYrMQwz/PbehNyD6TbPXRD2yG89zo0ninHvwL7v2WTqA1AYAr4b76bHovl9G90u F2gQ== X-Forwarded-Encrypted: i=1; AJvYcCU8S2N/PQ1Hv2zo4bQuUyQS0wYdxd3R6NGJ2RtIJEpFE3JMD/Ihm4qUkuUE3z154xYluUbljHJ+PLuulOhe@postgresql.org X-Gm-Message-State: AOJu0YyThqqoKdFALsd5BI6BZAW8HQr7GPavoRavDJw+j1Qkqe8okuMY +Q8m8328kxG/EB8DZk+W1OJL9FrPzFoTAmwqOWyPznToCWRopNkIHluRv0WNA39t4/COHktOKjI = X-Gm-Gg: ASbGncuWW7jd1xSxzRLfi9to4zD6hUY3bp4wAQbzKeMC2A1Rnf52aVpwpuuI9/xvY7S zLWiuIx7nfp64ci5M5keSAvxNrrKevhZR0z95zAi5GIboS0BxYoRbFUJFluq3rhbojIO3mlLTOh EpXg9fSNqDtBvljFWDk0foep3Bi77BQLpRFIp4H1pz3ve9ajhluRabJ9MD7zcNskIPY1/0hrpTo WeJVU23XF0c5yW0nL6KFUfzQk8dQ0tJNz6iDfYKsBMsEURUMDHLefoQQeBkjQfqaQeKaknq4PxQ NgVe+ir6YkiqCXD9OMH+vgTw8Q002NwKKH42DeQUoBqTnLr1pG4qomM+1URqe3gEL8p4ONLMPqo r X-Google-Smtp-Source: AGHT+IEVU/K23+VoDeMqdM2AVrLPdePE8tPN5FWKavVqW0qEG05ExSARMDnVk+l6QuL8XZgM8qilxg== X-Received: by 2002:a05:600c:1385:b0:43b:cf12:2ca5 with SMTP id 5b1f17b1804b1-43ecf86a9fbmr120742005e9.8.1744053936906; Mon, 07 Apr 2025 12:25:36 -0700 (PDT) Received: from [192.168.4.34] ([185.231.138.91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c30226f1fsm13034611f8f.95.2025.04.07.12.25.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Apr 2025 12:25:36 -0700 (PDT) Message-ID: <692a315e-6dd8-4194-8c7f-c45425852e77@cornfield.me.uk> Date: Mon, 7 Apr 2025 20:25:28 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Slow timestamp query after upgrading from Pg13 to Pg16 To: Laurenz Albe , pgsql-general@postgresql.org References: <27b2975b-c078-45cf-815d-eddbedbda153@cornfield.me.uk> <092224fb0376bbc6a5f777199dde3cb9cd1ebf99.camel@cybertec.at> Content-Language: en-GB From: Simon Windsor In-Reply-To: <092224fb0376bbc6a5f777199dde3cb9cd1ebf99.camel@cybertec.at> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi We used pg_dump|pg_restore to migrate the data. The full explain plan is at https://explain.depesz.com/s/742M. The SQL explain (analyze, buffers) select count(*) from consignments where (req_status_tstamp >= '2025-03-28 00:00'::timestamp and req_status_tstamp <= '2025-03-28 01:00'::timestamp); takes 2-3s with the old Pg13 DB, and over a minute with Pg16 After spending many hours looking at DB settings and Statistic settings I am at a loss/ Simon On 07/04/2025 15:51, Laurenz Albe wrote: > On Mon, 2025-04-07 at 15:48 +0100, Simon Windsor wrote: >> After upgrading a Db from Pg13 (Centos) to Pg16(Ubuntu) some queries >> on a simple, large table (200M rows) are very slow > If you used "pg_upgrade", did you ANALYZE the database? > > If that is not the problem, we can't guess what your problem might be > unless you provide EXPLAIN (ANALYZE, BUFFERS, SETTINGS) output for auch a > slow query. Ideally, add the same information for the fast v13 case. > > Yours, > Laurenz Albe -- Simon Windsor Eml: simon.windsor@cornfield.me.uk Mob: 0755 197 9733 “There is nothing in the world that some man cannot make a little worse and sell a little cheaper, and he who considers price only is that man's lawful prey.”