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 1wd6tx-003tdV-2J for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jun 2026 13:47:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wd6tw-00BMQu-10 for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jun 2026 13:47:24 +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.96) (envelope-from ) id 1wd6tw-00BMQg-01 for pgsql-hackers@lists.postgresql.org; Fri, 26 Jun 2026 13:47:24 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wd6tt-00000000LKZ-3p3J for pgsql-hackers@lists.postgresql.org; Fri, 26 Jun 2026 13:47:22 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-c0e124d2a21so94667866b.2 for ; Fri, 26 Jun 2026 06:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782481640; cv=none; d=google.com; s=arc-20260327; b=q2Rl8kyYO0WsI86MwNTFK8am8qZSW7Ei3OQd87grF2WSe293kKzojgx2AC3QoWjiOi VeNec2ZaDPdeJzXa+bhiG6kI0HZEYxTI1RyXVGPVVzYv37WjBvTgypdytUHEBQzZqPn6 nZe3+gj/jOuOmuiu3oASJWpnccSGKa9huFvJ6n0kswgGgVkr2gJDFkPwXUgvVyOK3S7F rZGI72owshNTxWe/AwTN4t64ZHvoZtsUwMrBpLCQg2F5iCn8rQyBMEnfPNO+/1GnYVTl AACBQoTQ3IEY0lrvyCpXSAEm4uczo+auBBNWwLPBWfYU7KSwyAJ06SAJi5l8A46R4In/ lIHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=0Pt5pZmJcsnn1nx+kHd9O6F1MNflB6asFh5mNPJ1TO0=; fh=WD2N50YNLeDSspZluktt2QImVfiJgeMG5fCxpTTQ3FI=; b=V4sxvf9x2rKA01s5mhuRnSDYLYZhVT14NKX+dMbuH3ZATCOgXDuqGKOORowfKibwCE 3qYSidiOcYO8d9V+BZ0wCKX312xlN0Nmd+Hr3jrYow8MCSFI25Fk+eJbMEMBnLiUwUCS BIZaDwpNZEE8LhZSXkrDMlvoiJiOFHVKLxllGyvXNJg7JT0qG5RM8lMv/bMGMl96cm7L qTEUCNTLM6h1nU/CGlzrMq3s/KtkYk020CtY8urO1j/vR4nvvBrJ9oezQ1qPyfUgY8mO NGBocZLKEK+EB9aX1/A0tgDje8W138CoupVAa0x5uWQjrU0x24w1H7cEOaZpHvf48DeX Z5WA==; 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=1782481640; x=1783086440; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0Pt5pZmJcsnn1nx+kHd9O6F1MNflB6asFh5mNPJ1TO0=; b=RzOb73mrG3h+WoURdQAv+QtAzTecKHO2r8W/wxhmTWc8cqCxm9jgFLPvWggXzdaQdG Ly16VRQptelOqjLMgKYMdwrZGjK28TXHy5UR9LbZVc/ylBAvKUr6hgx3fvSEiO8HcEN0 4KQCTHuQKXRmIdeQo/qRgo4JEdiH/CniQl1zUqfuansxlmYZXnLXwD8JW6X+psX+/9OQ VyrJhLogyanQzsk4Ojl5eaMfle6+CF6aNC8119ZR1A8GLjwa+K0+9onyoLXOzf39s8Ok R97JLtIE5nkH/Ss+U5tEotb/YpmOFty6KZZIV/SMnFEGPUCGX2h26IBHsvz2qc19JNg9 so8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782481640; x=1783086440; h=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=0Pt5pZmJcsnn1nx+kHd9O6F1MNflB6asFh5mNPJ1TO0=; b=ImkpXuowy9K0J+N/+AmgZfLRwe2KNMFN+a0Zvk82k4CZsjw8K/AbxeTf0umZUJw4FC BchjYO6ezbt6+CKIkWTGZiv3VVNKBECIRRipWxJ4rGByuaN7ZCjMpOYptS9IOuN1ZSL9 bjmdbUzjNu+m8hUYKl+f79uizP+QqVIXMdPBMZ+to+yR0oVD7EPJwssIXHJhXVkQiLga X2Y9fYBffM9V3jWQUsiElgNxZn7OMcnHQ4lcLktOZBaMKzjDMBXtiynG5cTUlRXUAwgX TuqXWPU26B1cHaAexm7JouWlYFLbUzw87E+kLlunRbICB/N3hWG4n1zJttFpvfJuk7+s kIlA== X-Forwarded-Encrypted: i=1; AHgh+RpBUT9DLCuHFTzpYQbFRWACT2+Wxqp4zpWAR4LMNmbVsvHGNFaTv4cyqIWgC1GV8SsSKnGmDfOSdFfHgmqZ@lists.postgresql.org X-Gm-Message-State: AOJu0YxckHya2s3nFQjgtUJBjS8gQ+H67EG02OCwNIjKSRLeki7c3Lav Q27fCOYbkbBfPW/KIWQOgOPw9k9ARlN+58Lb7XauCYY2c0Yrzcoxj0k2NfKsgIjwgjihiriDPvU nex+AgDaxOoa5fvonfFGNb7H8iI+AmTg= X-Gm-Gg: AfdE7cmAOjs3WPlARYano7suKCJY6ss1grLU4nLZB+5F53tXXUH93AtW3TiZEP+zBbV LJjBm1+sV7RXXXSUl3xHk0qg06rbS3VbT2tFHTB17/JhqdDreBDzYy3s4b9YFmQu03icEP85u1A 6CetXw5QqfqdwGjw0q/OROWxAVlHEcdEGtNw3USaSun/Fduf+08t5h/IDmePFADAh50fvO3yUsK XhfWhFxOCJ49HbI2AuMV5TrC1IBcWXKHmBVPh5AnyCEJuh5LAfye8e9yzgKuFjvcIvLL5wBFl4= X-Received: by 2002:a17:906:ef06:b0:c0c:9f16:90df with SMTP id a640c23a62f3a-c1205d8c0a1mr480964066b.13.1782481640014; Fri, 26 Jun 2026 06:47:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Borisov Date: Fri, 26 Jun 2026 17:47:06 +0400 X-Gm-Features: AVVi8CemQrQRA7C82xf9IqaAaNDiC7BpP5Eb4te4UXHazUFaH1oSEGMZyxQvAoY Message-ID: Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands To: Justin Pryzby Cc: Alexander Korotkov , Dmitry Koval , Alexander Lakhin , pgsql-hackers@lists.postgresql.org, Tomas Vondra , Alvaro Herrera Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Justin! On Fri, 26 Jun 2026 at 17:40, Justin Pryzby wrote: > > Thanks for addressing the tablespace issue. > > One more thing -- merging non-contiguous tables is currently refused: > > ts=# CREATE TABLE a(t timestamptz) PARTITION BY RANGE (t); > ts=# CREATE TABLE a_20260101 PARTITION OF a FOR VALUES FROM ('20260101')TO('20260102'); > ts=# CREATE TABLE a_20260126 PARTITION OF a FOR VALUES FROM ('20260126')TO('20260127'); > ts=# CREATE TABLE a_20260127 PARTITION OF a FOR VALUES FROM ('20260127')TO('20260128'); > ts=# CREATE TABLE a_20260128 PARTITION OF a FOR VALUES FROM ('20260128')TO('20260129'); > > ts=# ALTER TABLE a MERGE PARTITIONS (a_20260101,a_20260126,a_20260127,a_20260128) INTO a_202601; > ERROR: cannot merge partition "a_20260126" together with partition "a_20260101" > DETAIL: The lower bound of partition "a_20260126" is not equal to the upper bound of partition "a_20260101". > HINT: ALTER TABLE ... MERGE PARTITIONS requires the partition bounds to be adjacent. > > The goal seems to be to avoid overlapping partition constaints. > > If there's a default partition, that also avoids the possibility of > needing to move *some* (but not all) tuples from it into the merged > partition. > > I think there should be separate logic depending on the existance of a > default partition: > > - The existing logic seems to correctly handle the case of a default > partition, which is being merged (gap is allowed). > > - The case of a default partition which is not being merged is also > handled: no gap is allowed. Actually, this case was probably the > motivation behind checking that the partitions are adjacent. > > - If there's *no* default partition, then I think the check should be > relaxed; it's sufficient to verify that the bounds of the merged > partition do not overlap with any partition which is not being merged; Thank you for reporting on this feature! Yes, I think main motivation for not allowing a partition bounds gaps for merge was the complication in case a DEFAULT partition exists. Probably, this could be relaxed when there is no DEFAULT partition. Regards, Pavel Borisov Supabase