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 1tJ0pE-000SBx-H6 for pgsql-general@arkaria.postgresql.org; Thu, 05 Dec 2024 01:38:40 +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 1tJ0pB-003j7p-Up for pgsql-general@arkaria.postgresql.org; Thu, 05 Dec 2024 01:38:39 +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 1tJ0pB-003j7h-JO for pgsql-general@lists.postgresql.org; Thu, 05 Dec 2024 01:38:38 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tJ0p9-0016dP-Ul for pgsql-general@postgresql.org; Thu, 05 Dec 2024 01:38:38 +0000 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5d12709e262so349541a12.3 for ; Wed, 04 Dec 2024 17:38:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1733362716; x=1733967516; 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=6KPnmjpaLCakINUBGFTcTd4YlmzYs18+gBpQiAs2mtQ=; b=dxWzdtcsAqsWhH2+8EjVyq77MKjTi7R5UcjXNUoI2yuaAV4AJ4FJV10ODg0lNCZOvE FNUt5+bXC8FIuo1/K55jFg6X8EHT0NgfNroFAfFYAn/DXWcjszsfEtZkhuI9EwDolSwH O9NDJVQ/j+yUXO2LtiM+9wHJxBqissGyv56p10XDFAfPTXrzh1bSu2eRgDHwfiha2y58 TBIekYoIqxmDJYjk6DRy+D5V5DIR9Q7ih7iuNukMTqotJbCzggrDXN7/YOuqKRKh9UlX zlj2fgTpGWdbExK94U88y5bNZPml8NHgio7bQ0RF+UFhPCEucelc5xbib2mlRqHtr1nb 1SdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733362716; x=1733967516; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=6KPnmjpaLCakINUBGFTcTd4YlmzYs18+gBpQiAs2mtQ=; b=nwuqcElF5MD31eEO820AyJOkX6jmk0CF7WuSmzuZEIugd13jLcexBjOVraXIeU2qp4 UUvCdiHqstSrrNIyMp48UgqzyLAelaApjGmQsoBnlhlLxbJET8Te+uiiJQNfLQta9h+s TNglbFwrqG9lHWD5a1N6RBV63XkAp+2SR9Bc3sEhl9pZSUp3R+7E3USmOfyWroM57RES LtwvVX7qcKL0YRAiU/cA3MvNr5uMdwQoQEUAh49Xf6v13tEaccDetsND+p6gzKoucfJo HgCcWWZu9iZ7H/7YaOxSHJGOyNShOIOMvHIIM2ozvMmyuEoK1eVZbMAOpUf4KozBChOz kXNw== X-Gm-Message-State: AOJu0Yy9rkxV+AJNE0PosWG6er3TmkL2xdf8jb26d4reJpI0RUe4QvB8 LbVuCCDhdK0pbH2+cIha8GlAx7krjh17V+hr7rZ62R7TN1lKP7Eg1piM4WpZtlByhHCNBKW3DGM PtX4= X-Gm-Gg: ASbGncvLpoZzJNpB3v97Di2pdFoA8BT9ns+35z6f3dr01aHZCnzyoD6fKuoeCMH2nao XccFEAsfGe3v3qUfL4GS4InBCMbcLO4eHBSNCiNyZ38fuiS8L5u3j7UNMfyaUtex4K6mST4vBfO 48QiDxBX/zHBWuajelJirCd//8sTc+wfRu1Y3Qg3p37/mmmSvSC5rIuBYnOMOPxMuDAu7Qd/ggu ucPs7x42PYNLWRwRIR9ZykmHnWAlg39GpprD4XziQefgRNXOyfHwBBIM6VtrdnplwWd3YxTgBZi vayUvzldk+0xISz/D8ptdNKkRBf51ON+ZrFa7sQcDHo8o9RkMg== X-Google-Smtp-Source: AGHT+IELp6hONAODEbJ7LDrcqGMcWBI+Jj+OSKIN02bRSXJUOs0VBbV8psFhbebK9Q94MFMRYEMhgQ== X-Received: by 2002:a05:6402:4405:b0:5d0:aa2d:6eee with SMTP id 4fb4d7f45d1cf-5d10cb8017fmr7174735a12.26.1733362715537; Wed, 04 Dec 2024 17:38:35 -0800 (PST) Received: from localhost.localdomain (dslb-002-200-202-108.002.200.pools.vodafone-ip.de. [2.200.202.108]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d14c7986b2sm176315a12.64.2024.12.04.17.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 17:38:35 -0800 (PST) Message-ID: Subject: Re: Clarification of behaviour when dropping partitions From: Laurenz Albe To: Bolaji Wahab Cc: pgsql-general@postgresql.org Date: Thu, 05 Dec 2024 02:38:34 +0100 In-Reply-To: References: <928c165be24ee307c2fbaa29a2c6360eb8a00e02.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.4 (3.52.4-2.fc40) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2024-12-04 at 23:00 +0100, Bolaji Wahab wrote: > On Wed, Dec 4, 2024 at 6:20=E2=80=AFPM Laurenz Albe wrote: > > On Wed, 2024-12-04 at 14:22 +0100, Bolaji Wahab wrote: > > > I have these two partitioned tables, with=C2=A0referential integrity.= The tables > > > are structured=C2=A0in such=C2=A0a way that we have 1 to 1 mapping be= tween their > > > partitions. This is achieved with a foreign key. > >=20 > > I recommend that you don't create the foreign key constraint between th= e > > partitioned tables, but between the individual partitions. > >=20 > > That will make detaching and dropping partitions easier, and you will h= ave > > the same integrity guarantees. >=20 > Yes, this is what I have done. > But the whole point of declaring the foreign key constraint on the partit= ioned > table is to have it automatically created on subsequent/future partitions= . Sure, but then you have to accept the disadvantage that it becomes more difficult to detach partitions. I think it is less pain to create the constraint on the partition level. Yours, Laurenz Albe