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 1l1qF7-0002CP-E8 for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jan 2021 12:36:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l1qF6-00037q-BT for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jan 2021 12:36:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1qF6-00037j-4a for pgsql-hackers@lists.postgresql.org; Tue, 19 Jan 2021 12:36:16 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1qF2-0001oA-O7 for pgsql-hackers@postgresql.org; Tue, 19 Jan 2021 12:36:15 +0000 X-Originating-IP: 79.88.149.14 Received: from [172.16.255.146] (14.149.88.79.rev.sfr.net [79.88.149.14]) (Authenticated sender: vik@postgresfriends.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id F01F920007; Tue, 19 Jan 2021 12:36:07 +0000 (UTC) Subject: Re: Add primary keys to system catalogs To: Laurenz Albe , Tom Lane , Peter Eisentraut Cc: pgsql-hackers References: <348f3158-bf7e-c5f0-f33b-9e552e3d5481@2ndquadrant.com> <266949.1610921277@sss.pgh.pa.us> From: Vik Fearing Message-ID: <3aef6612-ea31-0fae-34fe-81505dff4549@postgresfriends.org> Date: Tue, 19 Jan 2021 13:36:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/19/21 11:46 AM, Laurenz Albe wrote: > On Sun, 2021-01-17 at 17:07 -0500, Tom Lane wrote: >> Peter Eisentraut writes: >>> [ v2-0001-Add-primary-keys-and-unique-constraints-to-system.patch ] >> >> [...] do we really want to prefer >> using the OID indexes as the primary keys? In most cases there's some >> other index that seems to me to be what a user would think of as the >> pkey, for example pg_class_relname_nsp_index for pg_class or >> pg_proc_proname_args_nsp_index for pg_proc. Preferring OID where it >> exists is a nice simple rule, which has some attractiveness, but the >> OID indexes seem to me like a lookup aid rather than the "real" object >> identity. > > I disagree. The OID is the real, immutable identity of an object. > The "relname" of a "pg_class" encatalogtry can change any time. > Since there are no foreign keys that reference catalogs, that won't cause > problems, but I still think that primary keys should change as little as > possible. This might be good advice for systems where the primary key defines the physical layout of the table, but for postgres's heap there is no reason not to prefer the natural key of the table. My vote is with Tom on this one. -- Vik Fearing