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 1u1n7m-0089v2-K1 for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 14:06:54 +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 1u1n7l-00GwKU-31 for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 14:06:53 +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.94.2) (envelope-from ) id 1u1n7k-00GwKI-PD for pgsql-general@lists.postgresql.org; Mon, 07 Apr 2025 14:06:53 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u1n7j-003Txg-18 for pgsql-general@postgresql.org; Mon, 07 Apr 2025 14:06:52 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 537E6met3394120; Mon, 7 Apr 2025 10:06:49 -0400 From: Tom Lane To: Fabian Lindfors cc: pgsql-general@postgresql.org Subject: Re: Custom index access method for primary keys In-reply-to: <872B0CA7-4483-4FC2-8CD8-0A5C08FC0942@flapplabs.se> References: <872B0CA7-4483-4FC2-8CD8-0A5C08FC0942@flapplabs.se> Comments: In-reply-to Fabian Lindfors message dated "Sat, 05 Apr 2025 12:34:24 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3394118.1744034808.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 07 Apr 2025 10:06:48 -0400 Message-ID: <3394119.1744034808@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Fabian Lindfors writes: > Hi! I=E2=80=99m working on an index access method that I intend to be > generic and to replace btree for my specific use case. I noticed > though that it doesn=E2=80=99t seem to be possible to specify an access > method when creating a new table and using PRIMARY KEY. There's some work going on right now to remove the core code's assumptions that only btree can handle unique/pkey constraints and sorting [1]. I'm not sure if it'll be entirely complete for v18 but the goalposts have been moved quite far. I think you can probably expect to be able to do CREATE TABLE mytable ...; CREATE UNIQUE INDEX myindex ON mytable USING myam (...); ALTER TABLE mytable ADD PRIMARY KEY USING INDEX myindex; It doesn't look like we yet allow direct "USING myam" in PRIMARY KEY, but sooner or later we might get to that. regards, tom lane [1] https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255= 197F55330%40enterprisedb.com