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 1u1sGv-009XGM-MG for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 19:36:41 +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 1u1sGt-003AOk-Hq for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 19:36:39 +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 1u1sGs-003AOY-Lr for pgsql-general@lists.postgresql.org; Mon, 07 Apr 2025 19:36:39 +0000 Received: from fhigh-a8-smtp.messagingengine.com ([103.168.172.159]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u1sGp-003yjl-1w for pgsql-general@postgresql.org; Mon, 07 Apr 2025 19:36:38 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 736041140205; Mon, 7 Apr 2025 15:36:33 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Mon, 07 Apr 2025 15:36:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1744054593; x=1744140993; bh=U7kkXbH2n1Beqz9iiGbPAico3vxukbz+oiDH7vObdZA=; b= l2ocabpif7bZW/NhjQuMCT8Tl2hWYhBCy/qgqIMniP8HbWYB5bkyK8OHPVtdWP11 Hbq60E129q7RMC55eb5FbuFc9I2DBDvuCBD4JK1LYCEHKaG7FWNPVgRtxD5prPZu 4o817JE75/zsofcp4FDW68GAX9Av6MNfmkcVjZNSBqf/YPDONDSihwwUEyv7IEJG RvTaWUWiBg29K+0vwYp5Oc213o1mn84JQfgxPMfgdO/AnVoTjbXDMvLGGVvdMfaU YZOQndVSjbfCaV2RNqt16s6yVgv7YYpo0uNuXJkvA3gIc0e2jD1WWEnn7hryoUYm nCHszZEGvX2JiQ/Pqgffvg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1744054593; x=1744140993; bh=U 7kkXbH2n1Beqz9iiGbPAico3vxukbz+oiDH7vObdZA=; b=wAGF9qWOnB3st6uTE ipy8US0ElhTqh0+z7xMcO395SUkN1ZO2dNcQbF1Fv8pd5gzWYVivAOFFF+WJOjEw qkjuiIp9XI50aTYZG1tDPucketMcomwiGmv6KWh+ziHv3Uac5dcoDZaoTS+jmwmE jBlB8+kR6DFXCqssOklUXD8DlmPU49S5F4ZCxE+66oi3EqMEzBFhmp7Qk6gDEeic fRjYU15ZLThtjYXy2Sl3J0ZjdRSM0EwOVBnBXur8Y5KhEm3tQ3X7Uuc90XDppp0a KIS0eaJT9ncTo89OswsNwXOaL+MVfoSrwYRJ6icMzz2qgrbHe9r6x9VE32HJP0rx jNtcg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvtddutdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfesthejredttddv jeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvg hrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeetheelueeigeehhfeh gfffgeehffelkeeffeeuudekvdegffejhfdvffdvtdegjeenucffohhmrghinhepuggvph gvshiirdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtg hpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshhimhhonhdrfihi nhgushhorhestghorhhnfhhivghlugdrmhgvrdhukhdprhgtphhtthhopehlrghurhgvnh iirdgrlhgsvgestgihsggvrhhtvggtrdgrthdprhgtphhtthhopehpghhsqhhlqdhgvghn vghrrghlsehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 7 Apr 2025 15:36:32 -0400 (EDT) Message-ID: <9653cc7d-3275-4255-ba4d-fba3778f67e6@aklaver.com> Date: Mon, 7 Apr 2025 12:36:32 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Slow timestamp query after upgrading from Pg13 to Pg16 To: Simon Windsor , Laurenz Albe , pgsql-general@postgresql.org References: <27b2975b-c078-45cf-815d-eddbedbda153@cornfield.me.uk> <092224fb0376bbc6a5f777199dde3cb9cd1ebf99.camel@cybertec.at> <692a315e-6dd8-4194-8c7f-c45425852e77@cornfield.me.uk> Content-Language: en-US From: Adrian Klaver In-Reply-To: <692a315e-6dd8-4194-8c7f-c45425852e77@cornfield.me.uk> 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 4/7/25 12:25, Simon Windsor wrote: > Hi > > We used pg_dump|pg_restore to migrate the data. Did you do an ANALYZE on the Postgres 16 instance after the pg_restore? > > 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 Do you have an EXPLAIN ANALYZE for the Postgres 13 case? > > After spending many hours looking at DB settings and Statistic settings > I am at a loss/ > > Simon > -- Adrian Klaver adrian.klaver@aklaver.com