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 1w84Yc-000BXA-20 for pgsql-performance@arkaria.postgresql.org; Wed, 01 Apr 2026 23:01:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w84Yb-002kAA-10 for pgsql-performance@arkaria.postgresql.org; Wed, 01 Apr 2026 23:01:05 +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 1w84Yb-002kA1-00 for pgsql-performance@lists.postgresql.org; Wed, 01 Apr 2026 23:01:05 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w84YY-000000005qQ-0noB for pgsql-performance@lists.postgresql.org; Wed, 01 Apr 2026 23:01:04 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-486fd3a577eso1888965e9.1 for ; Wed, 01 Apr 2026 16:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775084461; cv=none; d=google.com; s=arc-20240605; b=LA+sQBekMpDkxdeB7Ebi8qWne44YDPUvfvSMNUZvXZkT/ve/jh06ilJ5lrMwwVE1ac AG1M/uVn1+yfadwqD/lkyxtAVKPU3kGRmwsrNc3AJomDue/6LJLpbc2iySG/3SwpNoQz tseCTvTW/gLCuMiUJkcsKvGAIH0V8mdeE5qp3QdUiV7RouR7MC0h1a654TnR4Z0epLIJ t+g5hXdXGLTJ0iJcf3qXrUOzv6BASKJ2Tsb14s1VSdp7qzfs4zBwLel5nflxrEQEtGjj ShOMYa6gz09Doi4YKo4qUuccE70sjWy5zXGCwVt/Z4G2k1qkl+GFP8J/j2dDIJpCS5OG cMkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UlXJ+b5WzS/tGC8cbH5x36oCiEAKGge3By62E/xq0ng=; fh=3DDbSsh3NGKm1yyU84DUs862fo9afaknrOUdfcs5Q/w=; b=aN0fpsHa6hnUyeWFI9dcik1KV9f7Q2li5j0D83eGCHsQzG3gAlXQLvb2jEqdCUqHw+ T9ke18fUNFDV6o7H/jq34ZqR45Z8zSBriazYhJGLSE/umA1UfHmuQPur4YDaZrHsfdxt D3dp/sEZ/+WEGKoYE6izkh3stwEHyr3L6XwIc70S76+nTGSinWHePl77xbO8b7ArGKXl iQmwLP61hB8KXZU+NCID5mn6AYXfTiVeyj5Vj83E3av9OR6PNem2hLFLrFhjFaoXj8r1 5TJXXdYfqCvqCiuYQIKz8IIUu0PaC2rtvlqSWp1it17m33KUyW0Fe5TgZw0ylZwZziqs ehPQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775084461; x=1775689261; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UlXJ+b5WzS/tGC8cbH5x36oCiEAKGge3By62E/xq0ng=; b=aIiVLr58WckMLeraB4V2Wk4VorWQWqmeD+q5/eO+bmfuNMCx2howkIItlbH9A8QgJo 4GVP2L3k+g4v7+T9q6ZU+kO5QG57xPg+uFcieM2Ux4Mwmk4cY018kqlvn1USiLQaHL1W xDzRTEk/JNhqiZyekRlHbTnj7EhXvLFTZfRMn2Stl0NDbfFtjL3LzSwrL9FZmpyzKkaS /y2SUviJOxai1oAmMJMKAgSX8XjXuHRFp5zRh6sGOefxir0Er0OfRIGyE5bBktnuH40S yJ/qtqT/g9VJOPRlQqeXsNgkU6z55UUz4c5NjDcWDRD6+mM29zE5ze1wOF3vANu/my7F JLMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775084461; x=1775689261; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UlXJ+b5WzS/tGC8cbH5x36oCiEAKGge3By62E/xq0ng=; b=IVR9nN9W/nA4QH6yNR+HQpg3gGbac7fEadeaAqYEKicrwHAFQgvLRtHTWnrxJDf81g 20z3j64AGNr1VJjLIKiNWvfQzqnO2QaF3tWlvSrTZdQzYzwla+Kv+bGcJyho0T3GhPYv Vo/dtuJokkoIjY39Zszoo0sZMmS9C7kyV76NpKGfzZZdOHG3AK/evOOVA6BEBLNCyOn7 MI2gMv8tAJg+uYdEwdaofpu3n2JkLRDmsG20m12RxiO+ovy39Dx9fC1GVWsp8uKvgkba 4UFWY4kWqFv2W6WzU6Nj+gXUIAJ9JOOfk6ThqBBqfE134MmqRaxZm+9X+z8QQQ2YFcRY d0iQ== X-Gm-Message-State: AOJu0YxRKnfxXyELFOItkP/pcRJ2WgRhmDVx3dY7rRWnPtYJpm1ocD6i eJgbDuD8GlOUD5LYmTHd5VRF2QxA2PCbDzO/Ued2lGhPf3dz6h4F87vTHGfZZ+T/Q686jmQdQy8 JvV7Evgguposw2MMyW6Kt+/5NqGSqC80= X-Gm-Gg: ATEYQzyFodV61LfYmS/uSNwBk8xF8+LV6UQSZpx9oJlXbDW/xu+pCVm3xSNYL6uswGa 2+x3XgRg4vyX/BoY8oPcSFDvFXXuFKEQujLleZgKhGLbrKYgDqXnUjYEo0xQ9SQJ4wUdBI+wH8R tEnOdUG/XuIvC+wEC5g9niiCG0Qwj9OYq469xDO4t0FVUw0RHneD576c7p+A+6fylDwVZs9piFb Q6LvAxihidzllk1bQ+h5uW9oVz9YttpBHDfCmy+EVAywUWV9CEEsL/dcni5w29M+cw4M13ndNsw el8TiVj4DeFld8crarE6VKNkMLe+r+ZP/sPlVPtJEHIu1GpG1FOLSrmYyyCcUGx/nskeZBpDKw= = X-Received: by 2002:a05:600c:a16:b0:483:6d4a:7e6d with SMTP id 5b1f17b1804b1-488835e2617mr95101025e9.30.1775084461096; Wed, 01 Apr 2026 16:01:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Thu, 2 Apr 2026 12:00:48 +1300 X-Gm-Features: AQROBzA1JKh2IEHTdfH2T88nBcK7LQyliLH_39Y3OujQCGatJiWO6ASVIQsTI5o Message-ID: Subject: Re: Potential partition pruning regression on PostgreSQL 18 To: =?UTF-8?Q?C=C3=A1ndido_Antonio_Mart=C3=ADnez_Descalzo?= , Richard Guo Cc: pgsql-performance@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2 Apr 2026 at 00:57, C=C3=A1ndido Antonio Mart=C3=ADnez Descalzo wrote: > We noticed that one of our queries unexpectedly stopped applying partitio= n pruning on PG18, although it applies it on PG16 and PG17. The issue has b= een replicated on Linux and macOS. > > Failing to apply partition pruning significantly impacts the performance = of these queries. > > We recreated the issue using a simplified schema and query. Details on th= e schema, query and resulting plans in PG17 and PG18 are provided below. So= me changes in the query restore partition pruning in PG18, specifically: > > Replacing the view and date condition used with a sub-query or CTE with = the same condition restores partition pruning (updated query and plan provi= ded further below) > Keeping the view and using a single "group by" instead of multiple groupi= ng sets restores partition pruning (updated query and plan provided further= below) > > > Does anybody know if there is a documented behaviour change in PG18 that = could explain this or if this is a known issue? It relates to the "This release also fixes some GROUPING SETS queries that used to return incorrect results." mentioned in [1]. Basically, match_clause_to_partition_key() now sees a PlaceHolderVar rather than the Var, which is the partition key column. The question is, can we do the same thing in match_clause_to_partition_key() as we did for index clauses in ad66f705f. The PlaceHolderVar's phnullingrels are empty for this query, so I expect we just need to give the same treatment to partition key columns as was done for indexes columns in fix_indexqual_operand(). Richard, any thoughts? David [1] https://www.postgresql.org/docs/release/18.0/