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 1u1nmZ-008LQx-CL for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 14:49:03 +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 1u1nmX-00HKjc-S5 for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 14:49:02 +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 1u1nmX-00HKjT-CY for pgsql-general@lists.postgresql.org; Mon, 07 Apr 2025 14:49:01 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u1nmV-003UPd-1a for pgsql-general@postgresql.org; Mon, 07 Apr 2025 14:49:00 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3913d129c1aso3083919f8f.0 for ; Mon, 07 Apr 2025 07:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornfield-me-uk.20230601.gappssmtp.com; s=20230601; t=1744037337; x=1744642137; darn=postgresql.org; h=subject:from:content-language:to:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=5IMdEmQ9YeOi+H7Zthuhr20va1mn2vj4nyGJMknQtxc=; b=nthLi8m2JVizql/EeHsfh62fZ1BHFhOKDtB3ok1HoptLI1afu94qQvHr4NCyXPP3Eu YPdUq8YSGKA6wVJ0koCI1fHVCwTzQj3RI8e0NpAppowVFJtgQgKTmfCazZDFQDpkW8lL dotZ5NDfV8DQgUHCBvBcH24LuPzCmPBjLyoeObxZVoH2l/Yhjl7XyNB9DgbD3ShWKbNp 1e991FTI67ZkVsrc46REKdA5r+ep8GKxyUU1hRXFsqQ8VVyaud0dIyyd7cKVk4+djdEw MFmWQRH4eC5Tm0YzFV75GitT8294bR4MlGFRFmx7U0d6WaEGD9DAfDeSPkvd1vTU7YNo nsqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744037337; x=1744642137; h=subject:from:content-language:to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5IMdEmQ9YeOi+H7Zthuhr20va1mn2vj4nyGJMknQtxc=; b=ljkYk+cFBua/B6+pHKxOPfW0PDcviHkpLEQtKmBZQHpVTi+mJ2Jlzwe2iGC9H5J4z3 Ww9dFWYDsQqP379iM1GqrqzPRIQcJpb0OUKnYPQh82lmiuEeNZFtWP+4OmAfZDHooUk0 ULyfv/reIlSqHpv9oyeRC+7+9k4kcLnzzjoDglS5pjPUOIA6Mj79xcJzRit509JCviaD NQipXtyCDthAlvEbosIUZagD7Xf8Z5GV1FtGKQ1DYUcza8cg6fzCWW/yd7Tzf2rsZvay 6tBbrb99dkYsN02PWfsQrHdJBR2AsxOunetyivkA+iqSzIKX3m1DFOKLZbbiBudGHoLl r1PA== X-Gm-Message-State: AOJu0YxMVP9VvmL4T9D9OZphSNXA8e5haCRNDhrnuhvnB7Egy9sOf064 jsqWiZIGxJT3ur0ZxTE/CHssx00HrGipqLo13kZgLMkJlfkJCm/3s9vrhoNkF13wizxLQ76jBwU = X-Gm-Gg: ASbGncuBwquFWlnFqi3LUVfBW4rtPLa+eobCd/XgaofuOrfmwWXnJSLgxc0d07J75Ub 2YojLCbZloPAtWJu7ds81vpLwvOe6eOd8QpPCpOnZihk8aUzVIW64DLderOq2aXQ7lwtwX7ZRZs QpMIHywHjiQQM55xDkYXSlkdzpJfis/4ZbYOShvar8A1xT8XDWvCsfGs+/Og5nuIZGSnFoaYg2y cPEksguEIDVqHdoZlSYYgVMuyDErOWRGfpRTu+JdHGSB05zl2dyNG3md9r2Yh3ZCjbbrAYuWxHU /kZ1STjHRt9cz+udK7054p6tm2ftoivyNA8h8qQsF9QsXxtSKMgGagl1tY03VomgEcz+8QRKUMi 5 X-Google-Smtp-Source: AGHT+IG6jXKNDVJJ8p1vQ76PC0k6VanmS8XzZW7YkelBD41Mcjizi+dNe+3ff45Ma168J8vBfdj48Q== X-Received: by 2002:a05:6000:40cd:b0:39c:2673:4f79 with SMTP id ffacd0b85a97d-39cba94dcbfmr11701407f8f.26.1744037337055; Mon, 07 Apr 2025 07:48:57 -0700 (PDT) Received: from [192.168.4.34] ([185.231.138.91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c3020d98bsm12358045f8f.76.2025.04.07.07.48.56 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Apr 2025 07:48:56 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------l1stdQmTL7yHjYa5I9A3Bsb0" Message-ID: <27b2975b-c078-45cf-815d-eddbedbda153@cornfield.me.uk> Date: Mon, 7 Apr 2025 15:48:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: pgsql-general@postgresql.org Content-Language: en-GB From: Simon Windsor Subject: Slow timestamp query after upgrading from Pg13 to Pg16 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------l1stdQmTL7yHjYa5I9A3Bsb0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello After upgrading a Db from Pg13 (Centos) to Pg16(Ubuntu) some queries on a simple, large table (200M rows) are very slow id integer not null status char(4) not null status_tstamp timestamp <... other columns ...> If I create indexes on * status, status_tstamp * status_tstamp when status_timestamp is not null Queries for a set date range for a given status are good and perform similarly to Pg13 Queries for a set date range are VERY slow compared to Pg13. A few other queries on tables with indexes like CREATE INDEX table_col ON table (col) WHERE col IS NOT NULL; also appear to be slow. Any ideas, observations or comments would be appreciated Simon -- 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.” --------------l1stdQmTL7yHjYa5I9A3Bsb0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hello

After upgrading a Db from Pg13 (Centos) to Pg16(Ubuntu) some queries on a simple, large table (200M rows) are very slow

id integer not null
status char(4) not null
status_tstamp timestamp
<... other columns ...>

If I create indexes on
  • status, status_tstamp
  • status_tstamp when status_timestamp is not null

Queries for a set date range for a given status are good and perform similarly to Pg13

Queries for a set date range are VERY slow compared to Pg13. A few other queries on tables with indexes like

CREATE INDEX table_col ON table (col) WHERE col IS NOT NULL;

also appear to be slow.

Any ideas, observations or comments would be appreciated

Simon

-- 
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.”
--------------l1stdQmTL7yHjYa5I9A3Bsb0--