Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pjGso-0007j8-TH for pgsql-general@arkaria.postgresql.org; Mon, 03 Apr 2023 09:53:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pjGsn-0007tp-RW for pgsql-general@arkaria.postgresql.org; Mon, 03 Apr 2023 09:53:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pjGsn-0007tg-H0 for pgsql-general@lists.postgresql.org; Mon, 03 Apr 2023 09:53:49 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pjGsk-000biL-Tz for pgsql-general@lists.postgresql.org; Mon, 03 Apr 2023 09:53:48 +0000 Received: by mail-ed1-x532.google.com with SMTP id b20so114927400edd.1 for ; Mon, 03 Apr 2023 02:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; t=1680515625; 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=aDsgAvUAjdu2f+xIqYnUtS+T/+6/0zkVJi9e3kWVzfM=; b=RJdnmauPrL3vdxgJtEZW0XNAieVx6z0aW7EHTuEkLzULF7dVWB3tFd2hXyzADlrr2w 3WYpR1AKk7q8mBhKAOY6PIADKyuOrEkm2s9UMApcg/4bnZZkV/365HY8KcaEjdreoywR MEiBeHMwcY7DIudwO2knyaV+oqf54DHh9JhuQwxp68HLMiFaRg+GFeGIqZUPpTQH4TZZ cMMyeK0nNl0WiIDayGp8kNaamyqcKmQ8Spb7VrVVenVmmbw05kiuSYeZ0QfA50xO0XJu a3F/C/ofi7+tKMRh760vMOJ0fUj5RiMQEgKKQlt1fGXPMkLtvyDIpksO+GMP7LgfiAmL netw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680515625; 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=aDsgAvUAjdu2f+xIqYnUtS+T/+6/0zkVJi9e3kWVzfM=; b=QrucRmB4dkWgS+ZJKwCDGdS+h8zA4ayLdvCzi2C18Flt/zLupjpdhiOgnfe9VRkXp7 yYgVvIY9R84TpDixqe5rWMPqhqng37rrsebeHV5CIDxDgmTiW/QYdutxJeoNZpO6Zj30 0MUcCr9da6J4rbuv17Sa2KoOo5xI/N3G91pdOJFm13NDiRszlYqpNGZ7XtiIb9dvM+kw arWHKT01KV0GgwHcW5j7GX6QaVaJjafY9ktQzI7yhjAmyqLfFxl4aBNEcshBW4KBd9ke Gohsd8mF5xEU6JIXFFJYGDMcF2EzKC+DZe5Wu3Te5E5yv11WRBsJexqRAOVVdvLCp6HM +FCw== X-Gm-Message-State: AAQBX9fLO0+rRhMfOeunOL4LVi1embwjZfPgiQUKm1YbewpPGiY6Sqdc r3RXkNXdNy6gxb6h7n6bdsvUwQ== X-Google-Smtp-Source: AKy350ZfpGgUaIAjkyCoP+b0IihIyqoy0fnHkAale/1c2uSZ9KYjjH4iRIiUosVUtcXXTpOQAorECw== X-Received: by 2002:a17:906:f2c9:b0:93b:62f:82a3 with SMTP id gz9-20020a170906f2c900b0093b062f82a3mr36449695ejb.6.1680515621436; Mon, 03 Apr 2023 02:53:41 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:6aca:140f:2a2:608:8640]) by smtp.gmail.com with ESMTPSA id u25-20020a1709060b1900b0093e39b921c8sm4278051ejg.164.2023.04.03.02.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 02:53:41 -0700 (PDT) Message-ID: <8f38668f92ce878b63998aee42d47dd5a91dd653.camel@cybertec.at> Subject: Re: Question on creating keys on partitioned tables From: Laurenz Albe To: Siddharth Jain , Tom Lane Cc: pgsql-general@lists.postgresql.org Date: Mon, 03 Apr 2023 11:53:40 +0200 In-Reply-To: References: <560122.1680278819@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2023-03-31 at 10:35 -0700, Siddharth Jain wrote: > Is following correct? >=20 > when a PK is created on (X,Y) on the parent table what happens internally= is that the > command is run individually on each of the child tables. nothing more. no= thing less. If you are talking about inheritance, no. Creating a constraint on the par= ent table has no effect on a child table. If you are talking about partitioning: If you create a primary key on the p= artitioned table, that will be implemented by a partitioned index. That partitioned i= ndex consists of a unique index for each partition. So I guess that is more or less what= you mean. There are some differences between a primary key on the partitioned table a= nd a unique index on each partition: - the primary key is a constraint, so it can be the target of a foreign key - the primary key will force a unique index on each new partition - the primary key keeps you from dropping the unique index on the partition= s Yours, Laurenz Albe