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 1teys9-00Gkfn-JZ for pgsql-performance@arkaria.postgresql.org; Mon, 03 Feb 2025 16:00:30 +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 1teyr9-00Eine-OY for pgsql-performance@arkaria.postgresql.org; Mon, 03 Feb 2025 15:59:27 +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 1teyr9-00EinV-DR for pgsql-performance@lists.postgresql.org; Mon, 03 Feb 2025 15:59:27 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1teyr5-0033t4-0z for pgsql-performance@lists.postgresql.org; Mon, 03 Feb 2025 15:59:25 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4361e89b6daso31752835e9.3 for ; Mon, 03 Feb 2025 07:59:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1738598362; x=1739203162; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=P5NlLaloNl0JYtLKN8Lrbwf3dOFm845xVxkXyewLgpk=; b=Az3smMrab+yJDwIqc55cUuaIwsplA+6BiC6yR8VTCAUNaZSUHOQy74gOCD03qtEwxq z6uVvxm6hTCtHiubHlTxBca4Isx9qqzE8/sPXECM4ai3jP6SNPtXqmpmIDKCDai/JZyG ww2wgQrpGL6YL+Yu0OuBAgYIilMw2LnQzlS5pUX4OVUtMhkPkLjwC7KWCBbY9gHDtg1/ Kn7O0ZvQM/GaK9uTgE6JhAqBIwLBz6fGsS1miDBilASRcSXvKQvPE7OQPb113uHWZGHc yB2kOGJ1zgLVHvMgts1Cr2lFZkZK3v9Mb3z30lRdFc6rv70Rhi9nWdHNR2rOzXMnQWsx ZGDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738598362; x=1739203162; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=P5NlLaloNl0JYtLKN8Lrbwf3dOFm845xVxkXyewLgpk=; b=rbAbBRGQ4YK33VJxAUpPwejTdyYEusP1vvx/MWf4zfdXY0abcm8XnWnQIU6Nt058z0 p0Uo32wIGXQVi9D6pO6KpSHDQfz7wFPV/Ycfikhms+LTKLvOo0WYD10HYa3kOVisasm8 KjYssguokPB8WXZeCq3iD+MahndsB5A0eg70vEo0oYSNpTx+2TC0E9Z5L4urrFVsvzd0 Ezz8P1ssu4ZFxeSB4cYtdbfKP7rygG25HDfQpQHOzReInJhzKyI5r8ThkGXRuE5ons6P 3r0p7nFQADF159yNMJxlXYTSLalOJ28kr9BVuE0CHFrK0BfToxtbqLbCTG1cV3IU6i+J 9cYg== X-Forwarded-Encrypted: i=1; AJvYcCWuQJApt6W2mtJHJZJnJNPsR8/+ixGBLh/uymCV1j1czRgRpEYBgsV11dr/gkX/k4oNo6Fdf9AM3YcWYtZs871Wfw==@lists.postgresql.org X-Gm-Message-State: AOJu0Yx0Ks7+vbrRS6+YmgbLUNDRnNQVl39OFLMY6dU+m9r1v4/iQTS7 Rgx6gL2mxN85ntgkOy4i/TOtPCGUtHp1EvPpTYuScnZ7LgWhglWXwGUQ5pZBwxqzfE2I4QtSnD2 +N54= X-Gm-Gg: ASbGncsJOZFJnXOj1PZz/EkqaXBU0TgpnrvWDDipd1WOCPDeOc700mczQ2IVOru8kmL JicT6OpE5pTMZNe+NsP81izns58U+Fp0iR3Dw/M/MHb0VOojw+Mu3eRfcp8ssHz8Vo6r0NnbiGO DGu1xUEc6Rm5rBMnwkquGZWADFOA/iapyfVrjrXyU5PgtUy04byHOq+8/+MXlRWrS6naj/E8SFm Q84TMwIueFpJErBcEbE9wHsPVSIcvcX+A1g1aNs+0hs/Pii8ZmdQoGDiZqtNLHV7ECotqISR+Uc /GUAJDF7RzSRfSNhAMXNqJGbAErA+RxD4EcRhA== X-Google-Smtp-Source: AGHT+IHnEL9jBnqb+8H9g1crAArN17ri9imHPSlAcih00gYtQ+xc1ht0p4QVc45Smor8H7/k3N/hCw== X-Received: by 2002:a05:600c:68c4:b0:438:e231:d35e with SMTP id 5b1f17b1804b1-438e231d655mr169392545e9.0.1738598362493; Mon, 03 Feb 2025 07:59:22 -0800 (PST) Received: from localhost.localdomain ([2001:871:255:9ae3:244c:7859:2776:53b7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38d9ea04694sm3662566f8f.22.2025.02.03.07.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2025 07:59:22 -0800 (PST) Message-ID: <43ed5a72fdfdd44fa046d8911c496364a3eb9231.camel@cybertec.at> Subject: Re: Performance loss after upgrading from 12.15 to 17.2 From: Laurenz Albe To: Tobias =?ISO-8859-1?Q?Orlam=FCnde?= , pgsql-performance@lists.postgresql.org Date: Mon, 03 Feb 2025 16:59:21 +0100 In-Reply-To: <4450d336-5981-49ee-b225-70d0fd39fc31@linux-guru.com> References: <4450d336-5981-49ee-b225-70d0fd39fc31@linux-guru.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2025-02-03 at 15:11 +0100, Tobias Orlam=C3=BCnde wrote: > We are currently in the process of upgrading from 12.15 with Timescale= =20 > 2.11 to 17.2 with Timescale 2.17.2 > On our pre-prod env we have already upgraded and noticed a remarkable=20 > performance issue vs. the so far not upgraded production environment. > If we run the exact same query in our pre-rpod env, the execution time= =20 > increased from ~ 250 ms to over 377k ms. > Changing random_page_cost from 1.1 to 4 does not help, but changing=20 > work_mem from 64 MB to 256 MB helps, whereas any value lower than 256 MB= =20 > does not help. The prod server is configured with work_mem =3D 50 MB and= =20 > is executing the query in 13 ms >=20 > The Hypertable has been created on column received_time with dimension Ti= me. >=20 > In general, we see, that, if we are lowering the filter period of=20 > tick.received_time to ~ 14 days, the query is perfomant (on pre-prod).= =20 > In prod, neither in- nor de-creasing this does significantly change the= =20 > execution time. >=20 > My first assumption is, that somehow accessing the compressed chunks is= =20 > eating up all the time (which we could also see in the below's explain= =20 > statements). I somehow tend to point to the compression methods which,= =20 > IIRC, significantly changed from 12 to 17. >=20 > Maybe someone could have a look into this and guide me to the right spot= =20 > for further examination or even solving this issue? The difference is here (there are two instances per query): Bad: -> Seq Scan on compress_hyper_6_106_chunk (cost=3D0.00..6428297.17 rows= =3D2518 width=3D321) (actual time=3D196292.784..196292.784 rows=3D0 loops= =3D1) Filter: ((_ts_meta_min_1 <=3D '2025-01-29 14:31:36'::timestamp with= out time zone) AND (_ts_meta_max_1 > '2025-01-01 14:31:36'::timestamp witho= ut time zone) AND ((xx_id)::text =3D 'XS2991917530'::text)) Rows Removed by Filter: 30492771 Buffers: shared read=3D5894720 Good: -> Index Scan using compress_hyper_6_106_chunk_xx_id_xx_feed_id__ts_meta= _min_1_idx on compress_hyper_6_106_chunk (cost=3D0.56..1571.33 rows=3D2518= width=3D321) (actual time=3D0.010..0.010 rows=3D0 loops=3D1) Index Cond: (((xx_id)::text =3D 'XS2991917530'::text) AND (_ts_meta= _min_1 <=3D '2025-01-29 14:31:36'::timestamp without time zone) AND (_ts_me= ta_max_1 > '2025-01-01 14:31:36'::timestamp without time zone)) Buffers: shared hit=3D4 As a first measure, I would run ANALYZE compress_hyper_6_106_chunk; or analyze the partitioned table. It might well be that the statistics are= off. If that doesn't help, it would be interesting to run the query with the low= "work_mem" setting, but with "enable_seqscan =3D off". - Does PostgreSQL choose the correct index then? - What are the cost estimates for the index scan? Yours, Laurenz Albe --=20 Cybertec | https://www.cybertec-postgresql.com