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.96) (envelope-from ) id 1wdCLa-003x9f-0X for pgsql-general@arkaria.postgresql.org; Fri, 26 Jun 2026 19:36:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wdCLW-00Cdk3-22 for pgsql-general@arkaria.postgresql.org; Fri, 26 Jun 2026 19:36:14 +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.96) (envelope-from ) id 1wdCLV-00Cdjs-2J for pgsql-general@lists.postgresql.org; Fri, 26 Jun 2026 19:36:14 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wdCLS-00000000OrI-3Dll for pgsql-general@lists.postgresql.org; Fri, 26 Jun 2026 19:36:13 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2c7e8df1d28so1036285ad.0 for ; Fri, 26 Jun 2026 12:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alaska.edu; s=google; t=1782502568; x=1783107368; darn=lists.postgresql.org; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-type:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=n2ugQZzbOFvhAZzC9NY28ZJEkn0JxeqkVXZj1CxxkGg=; b=Z+bchHm8AzpYYFiG+xscVjCpeyb/zM8e43R+DByORIj1oMXt33mLbAJAq7nXxQ0qw4 vF3kQ1F6mwDr8G+vdiv+jz2mfs2VUrbfP9DQSLbP/zrY7PWDAyn8d6i9cHO4ecWnBW1G F/Rz1Xkexx1PW6raRfqTMKqESZR45YOQocD1QGlnFOQW8eXmNJl1eykKLuDsMv8YC7tz 6Alk69RZWi6a69D6wE1jTFziV91EyhW4WOOrBtLe0Ghhw6hYPK8zQt6JYOUrDESFg5bB nJJLR886cXIzYkGPI/dC7Bl9GMFD0yaUmCCLwN00j1jLXsITXsKFQ3qeeHsJfNFVljpI pU+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782502568; x=1783107368; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-type:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=n2ugQZzbOFvhAZzC9NY28ZJEkn0JxeqkVXZj1CxxkGg=; b=E6KERnm3di0ltXueOQjkZF5z1KSXDS8v8F3IeoMlZXdXlx3OwB8UJlHPevSWM+DOx+ HKcJZuoz3RCudtrfSBnVm1W8mS/MyChAgB4rMG9Md5b9z2uYlQm1/saAgvkE1n68Y4FF nBZ/ux4969/FuThEJPM6F74984K9Vsbop2SIhAVj9siWbTtu4QS980WoxyphxZvzagfG JS5Ik/Fsze665M1qHMKPTmRrIA/TeLewTK1WM2I4qbVzWEJMGFIHYnGfyHmV5aM5HNI8 zo4SR8aXTgJKFtyFpm+YDIj0r9yNt2PCfE3WN3nKQyZJFQTJwRvYNW8lRoD4JT7FquUp WbPA== X-Gm-Message-State: AOJu0YwimgvgT8EGQ1EKd1ZV7oaFMaFPdthzDUI+tKSpllrFSCdP2cs1 6R1/IloHJO9jLrgT+YEKiJtsUZ6rdoIebSnpwL/CmoCduoXYcsORdMdj6zPGzVx34TvzS75w1T0 MAiwpXi3VnXBnPjcC7za5JM1dv2Fr2W9UqqxJTOIFGegOk2mrTX05Q5kmgPWDdhfwHMfDdNpv8E Tfucc92vIas7wyz/01OXgAdFNeymKOhQnI/Im/uDupfAuC/CZvK5YhDbmG2Q== X-Gm-Gg: AfdE7cm+vd3MJGeLWSM8ZjI1h0ChzRS3gazxMPyy+xK4q4+8AGs2VzqTKXhoxmfzurw OXsgseexSIGYd7dnwboPxrmeEnM0/QFfKEWko9h6xqNz4MohxoUNkM6+wqdGeqZIjJ4wlaJha8V 7Wf6qn7WOBM7CQSqO/C6Ce9tqsCSBP3WB1LUhI8CV0W2TsSWWfmuGX2hj1MtNzO87/AibP2sb9c qvMFqugPd1h63cw7XuwIvCbujl7CtPAye8eH139uCsKNYfg8aGSOoVKnENvuoOcaU8rEBQ80sbr V+56MKRchMaFUCjVx8vpvraCmvlE8NsYGXscWUKNtgGW2hqmFAywDfbb0w9GP+xMn5PRZmePbJS cXhta1ifN0nINsIqXQ0Yx/NbW1tGMv1hMdHBM3+bzctqEo6Eg2ChcuL5L2oZfu/9L7rt1GUXWzl XUGYNuGnzp4EBvX93LeC3/Y36fhgX7sXovKOzyq8kp6cykqaJy8HHyEAZWgh9eLEWh4urWULXJc 7zdp4go X-Received: by 2002:a17:902:ea0a:b0:2bf:13f3:4d3 with SMTP id d9443c01a7336-2c7fc36d0d7mr41338885ad.0.1782502567546; Fri, 26 Jun 2026 12:36:07 -0700 (PDT) Received: from smtpclient.apple (63-140-92-92-radius.dynamic.acsalaska.net. [63.140.92.92]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c7f65088cesm44025875ad.80.2026.06.26.12.36.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2026 12:36:07 -0700 (PDT) From: Israel Brewster Content-Type: multipart/alternative; boundary="Apple-Mail=_C92A34D1-FC18-444F-8303-8F7589B95552" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: PostgreSQL 15-->18 slowdown? Date: Fri, 26 Jun 2026 11:35:55 -0800 References: <4A6D9280-1409-42A8-9A1F-99E2A558E2BB@alaska.edu> To: PostgreSQL General In-Reply-To: <4A6D9280-1409-42A8-9A1F-99E2A558E2BB@alaska.edu> Message-Id: X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_C92A34D1-FC18-444F-8303-8F7589B95552 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jun 26, 2026, at 9:58=E2=80=AFAM, Israel Brewster = wrote: >=20 > In postgreSQL 15, I had the below query that worked quickly. Now, I = make no claims that the query is the best possible, or even a good = query, but it DID work, and it did so quickly enough to be un-noticable = when running. > ... Some additional information that may (or may not) be helpful: in the = tilt_data table, there are only 15 distinct stations (out of a total of = 177 stations) across 407,032,436 rows =E2=80=A6so the query planner is correct to think that if looking for a = single station, it will get a large number of rows=E2=80=A6at least if = you ignore the LIMIT 1. I did manage to find a workaround: If I change the subquery on tilt_data = to this: (stations.id =3D ANY ( SELECT tilt_data.station=20 FROM tilt_data=20 INNER JOIN tilt_orientation ON tilt_data.station =3D = tilt_orientation.station WHERE tilt_data.station =3D stations.id )) as has_tilt, things work better - still not as fast as the original query with = sequence scan disabled, but fast enough to work with: = https://explain.depesz.com/s/bki5 =E2=80=A6but not only does that feel ugly (to me at least), it=E2=80=99s = still roughly 4x slower than the original query with sequence scans = disabled=E2=80=A6 Good enough to get me back up and running, but not = really a great solution, I don=E2=80=99t think. I might also try a = lookup table (materialized view), but I don=E2=80=99t know how much = better that would be, as I would have to refresh it whenever the data = changes.=20 =E2=80=94 Israel Brewster Software Engineer Alaska Volcano Observatory=20 Geophysical Institute - UAF=20 2156 Koyukuk Drive=20 Fairbanks AK 99775-7320 Work: 907-474-5172 cell: 907-328-9145 >=20 > --- > Israel Brewster > Software Engineer > Alaska Volcano Observatory=20 > Geophysical Institute - UAF=20 > 2156 Koyukuk Drive=20 > Fairbanks AK 99775-7320 > Work: 907-474-5172 > cell: 907-328-9145 >=20 --Apple-Mail=_C92A34D1-FC18-444F-8303-8F7589B95552 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On = Jun 26, 2026, at 9:58=E2=80=AFAM, Israel Brewster = <ijbrewster@alaska.edu> wrote:

In = postgreSQL 15, I had the below query that worked quickly. Now, I make no = claims that the query is the best possible, or even a good query, but it = DID work, and it did so quickly enough to be un-noticable when = running.
...

Some = additional information that may (or may not) be helpful: in the = tilt_data table, there are only 15 distinct stations (out of a total of = 177 stations) across 407,032,436 = rows

=E2=80=A6so the query planner is = correct to think that if looking for a single station, it will get a = large number of rows=E2=80=A6at least if you ignore the LIMIT = 1.

I did manage to find a workaround: If I = change the subquery on tilt_data to = this:

        = (stations.id =3D ANY (
          =   SELECT tilt_data.station 
      =       FROM tilt_data 
      =       INNER JOIN tilt_orientation ON tilt_data.station =3D = tilt_orientation.station
          =   WHERE tilt_data.station =3D stations.id
    =     )) as has_tilt,

things work = better - still not as fast as the original query with sequence scan = disabled, but fast enough to work with: https://explain.depesz.com/s/bk= i5

=E2=80=A6but not only does that feel = ugly (to me at least), it=E2=80=99s still roughly 4x slower than the = original query with sequence scans disabled=E2=80=A6 Good enough to get = me back up and running, but not really a great solution, I don=E2=80=99t = think. I might also try a lookup table (materialized view), but I = don=E2=80=99t know how much better that would be, as I would have to = refresh it whenever the data = changes. 
=E2=80=94
Israel = Brewster
Software Engineer
Alaska Volcano = Observatory 
Geophysical Institute - UAF 
2156 Koyukuk = Drive 
Fairbanks AK 99775-7320
Work: = 907-474-5172
cell: =  907-328-9145




---
Israel Brewster
Software Engineer
Alaska = Volcano Observatory 
Geophysical Institute - UAF 
2156 = Koyukuk Drive 
Fairbanks AK 99775-7320
Work: = 907-474-5172
cell:  907-328-9145


= --Apple-Mail=_C92A34D1-FC18-444F-8303-8F7589B95552--