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 1vviN5-00FVUp-0N for pgsql-performance@arkaria.postgresql.org; Thu, 26 Feb 2026 20:54:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vviN2-00FVNV-2D for pgsql-performance@arkaria.postgresql.org; Thu, 26 Feb 2026 20:54:04 +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 1vviN2-00FVNJ-17 for pgsql-performance@lists.postgresql.org; Thu, 26 Feb 2026 20:54:04 +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.98.2) (envelope-from ) id 1vviMy-00000001SGo-2Ixn for pgsql-performance@postgresql.org; Thu, 26 Feb 2026 20:54:03 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-483703e4b08so11533395e9.1 for ; Thu, 26 Feb 2026 12:54:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1772139240; x=1772744040; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=7fiytIkbU1vSvjs3G0WMEa4DPBz7zJtaqGfLTXVNFVY=; b=GkG/IfZDWlV7nBULCZx6/iWryUqDxYf3GbPc9dA0TvseYg6jmo3ra20wTdvSQotG7o jrlu7njRoXn+qelgoVcVjSWoBWQM95AbDhE+zMxF9KdCuQ9DTtaySWSMGHpYvW0nQyRX b2wEDwXsZC9KROhXMX92CP9j6Q6Rl8Bxlss7ZUGwDph2Cg+Pw+5dDo4xJVsaNU2ceJNf K4gw7a+VmsuzRTBVASSD6HCpvN7RNYbWTO+R0PEbjWbBLHd44jBnxGEbK3QcAI1Nv2zX RQgi+mCNnKik06XEcBrU5WTFC3jlrGhhSGWCzFOdzfhi+nba1VxRMFB4Lb9f0zN+uOyZ UFUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772139240; x=1772744040; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7fiytIkbU1vSvjs3G0WMEa4DPBz7zJtaqGfLTXVNFVY=; b=dBVmr7ku42DdEUxCZ2U3p8TBbqRl94K6RSOsqh65w5uQVvMLZ5hQdpu3iE10hOes7Q nuawH8ovqHYMNpMatI/gGbpkRVbJxKTwN6lH0sMysvc72IYAFFiHaD7wNNvxsQEPWzqD 2jwQLQSxCC/DXpixQj2bbP8JPfpmGLMx1swam28a7znN2UtDlsMNr5OQ07FFPLybwogn E1svbArYzLzH/ONwjznOBnM+MzPgfDyLBUqZCrEAW0yOdGD5459y+nMVsKyTPr1VBlPg 6Xj6TSWmQjFarlLAkLsXxCG9zCuvQwmVu3hr7i/jt1YpYehmyGpse927/jwznsvczrNO MH0g== X-Gm-Message-State: AOJu0YzQCk53/4h07RRqEE20jjvey/sHxzx27O0zlXjWQstOH6OI5oO4 VI5T70MMjxEsp2ucjESSmQGDqNXO3w53OE4ya8OgWCGywcK0zqme8rnnk3m8wLViuo8= X-Gm-Gg: ATEYQzyIsptQbiTlTB3QnGW2fnisYfNkjIJ+XCoE2Ueot04mJA6UXZDH1eyUhYaxUNk /amiun6N58EzpH0Vc3Ka/aJAJQ/Xmv+COOhV8xKXsI5Ib4cBcZ458O3zMZOHYgss5wHCppVTPgn qiZZeROZv7b0WL7f19DiEn8yS6z6wNBCVaVrRArzIMcruu558Ykl2YFO++P3lVgYtsCA2lfVN7Q FpcyI0pJUITE/Ea0I6oaKS7CzuQPamwWZWGe5zi0oQArdu5SOSVtpane3cZYN1X0wPfxYPuid5R AlO5Bzi5STmmuMUVFNYyi/BUBrGIOolO55TztQcqsrb2gjye7FKwhfIXSrtsdAH2UFgCrhAnzbO BZovsXH3Kj976/PZs9ZfswjpbJ52lSu3kR+AxiT/H3D9Y2/vGaRQO/E24+9zc4ZOz6n+B5AvX9Q 8xPkyUWail6CYitg5gsYsDVKa8SFdCMhdEglrjIbcKgbRmuf/DYw== X-Received: by 2002:a05:600c:34c1:b0:47d:6c36:a125 with SMTP id 5b1f17b1804b1-483c993a0e3mr6927675e9.17.1772139240384; Thu, 26 Feb 2026 12:54:00 -0800 (PST) Received: from laurenz.albe-K4N0CV00F97414D ([41.66.98.207]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483bfba9566sm68114685e9.3.2026.02.26.12.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Feb 2026 12:54:00 -0800 (PST) Message-ID: Subject: Re: unstable query plan on pg 16,17,18 From: Laurenz Albe To: Attila Soki , Andrei Lepikhov Cc: pgsql-performance@postgresql.org Date: Thu, 26 Feb 2026 21:53:57 +0100 In-Reply-To: <33A1B02B-1FDD-4F5F-8370-26DA72490009@gmx.net> References: <64ddfe83-317c-4cf1-b04f-cb74d9f40629@gmail.com> <529E2365-6C3F-4BDA-9625-312F3A023C5B@gmx.net> <5bace3e5-3d6b-4f81-92a9-9ff4e9e5de53@gmail.com> <1C445A2F-3256-4F04-B55D-9850581FF39A@gmx.net> <0dd76506-053e-4a30-9f95-9dc324e8e1fb@gmail.com> <1388B912-7E9A-475A-93AA-67FB99A084BC@gmx.net> <0c8b9845-a2ac-4613-8075-45dc55911143@gmail.com> <45AA83DB-A6B4-43A2-879B-290E4A7845AE@gmx.net> <33A1B02B-1FDD-4F5F-8370-26DA72490009@gmx.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2026-02-26 at 17:15 +0100, Attila Soki wrote: > Increasing the statistics of dp_end_dat did not helped. With statistic 10= 00 > I was not able to get a good plan without setting join_collapse_limit=3D7 Reducing "join_collapse_limit" dumbs down the optimizer, so you are getting= a good plan by accident. I mean, you can try to rewrite the query so that the tables a= re written in the order in which they should be joined in the good plan, then set "joi= n_collapse_limit" to 1. That may be a solution if you cannot find a better one. Still, the bad estimate that I indicated in [1] is worrysome, and I don't q= uite understand it. Could you show the result of the simplified query that I su= ggested? EXPLAIN (ANALYZE, BUFFERS, SETTINGS) SELECT * FROM schema1.table_k AS kal WHERE dp_end_dat < current_date; If I were you, I'd focus on getting PostgreSQL to estimate that correctly. Yours, Laurenz Albe [1]: https://postgr.es/m/b2e372392b8a022da81b95b7c823a5729d7fd70f.camel%40= cybertec.at