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 1u82ok-00CU07-29 for pgsql-docs@arkaria.postgresql.org; Thu, 24 Apr 2025 20:05:06 +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 1u82og-003IIm-EW for pgsql-docs@arkaria.postgresql.org; Thu, 24 Apr 2025 20:05:03 +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 1u82og-003IIP-5W for pgsql-docs@lists.postgresql.org; Thu, 24 Apr 2025 20:05:03 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u82od-001qOy-0g for pgsql-docs@lists.postgresql.org; Thu, 24 Apr 2025 20:05:02 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-ac6e8cf9132so279561966b.2 for ; Thu, 24 Apr 2025 13:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1745525098; x=1746129898; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=xQkYYmxvNq23wW8kminxKqfkjKWElxUcEFaO1l9nRuM=; b=A0MQDFW4FreZ33xbwwIsLOzzkl2jNpJFELjh8D4riXWag/cCEJ8oswniiK6/Fv6vP+ a8A6QHM5lxnMlAgyGSRmK9laknqG610tea3sjZWW3P0Eu8Ek5xVBswb8ik0MWBV8Xz5r bvTVhCKvCVtynNtYxZLbVcOIrdOhp57qwF5wT0vALM/uuZR5gA06UYLSY8ZBFpWGCZMa S4eEK/x4h+ZhoDsgXtHJbousHYdgBQlZfmVKNDLzoYTOxl61SLJISxst+D2xaCdZVmTQ ADNdbUP1C0O2QeUAGJnor2nUGZkhTk1mL7KDyIRZeClRxA9MHmoIT5MvrdwBnUJl3bRY tRaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745525098; x=1746129898; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xQkYYmxvNq23wW8kminxKqfkjKWElxUcEFaO1l9nRuM=; b=loAxcACCnX9G0CMZPzi6ibhp5CWweWDy/ZCNsmBTqt8q0nW3C2RNLknWN9nEvvgMM0 YcKPPecJSaaiGrqYaUs8SIeFwJJ94JXYaBC6A1VsrCGbGXSqn3n3qxDcMdxxfpyvUjNU NzCG03+LAsq6ywYUuyWdQftcXKtG26lJG1iByieZ4ucBCir5TjoyAPh2IjnWdUxd6BhP /RHGmCuzZkFem03ufE1I44hwbqzIMMQDifARgU5VaK6BGOG+CmnWc9zK8Y0Eivp+4Pqx XqSTltXjfxyouam7HHNkrk5+NusiXqpeE2kTDGRvijNkqIeUY9zHznW09/kl/7z6lp7n rc3Q== X-Forwarded-Encrypted: i=1; AJvYcCWekQI4jeLBIZNG6AcDzEJvWhb1ywbNhK7iXEtQxJI8W/cEwp26OpZ0vtw4h4XknQTgt4c42OG7cY5T@lists.postgresql.org X-Gm-Message-State: AOJu0Yy2ZhbhQUMQdJLjDKAjnJ/qrDKlIUSfRZO/qyrvCKwPovh56WKP W1y1x9jomQeRXH9AjxfI87ZBN0Q7MvWv9p11TFzs/eNfGAEGrxbU38X05bbs1h8rheXMhJPCQ62 fuXc= X-Gm-Gg: ASbGncunEt3/qSk0pYkq7vNroFNjYdd0c3uVGi2Xm3asZXQEjZIQPd/tP8YRvNO6acc +1HWiC3Lqmm+8CddxbZ+wF7joaib2A3pT0kCJIl5g2Bl4J87cPhT73EF6mGxCFz/zHgL6n5HKdd avJoWigqIoprvvajN9B5d3ibOjTp/JJywbaICHZniEjcweWoWLFYWlMB14X8dZrEqZxVN4y3/IX f5tULiWdVJ+IxrU/z5++gkDYi8tjVfVsY7c+MGCS7LkeoUmOara1GX0KKSrIMy6BFIfuN4UeDxa gO8skDk4yljm7Wir6GHx8eovlG3Q0GCz0iYCq6/g+zS/uVdYgQVjz2ojBQ4k X-Google-Smtp-Source: AGHT+IEpTtA+ERWXqcdufvRQfTzZaTpkK4tsqwGLCvwdQ0qpKSgOzJqNWDlutYP7iN8AuQjfLrxK/Q== X-Received: by 2002:a17:907:3c96:b0:aca:d48f:4d48 with SMTP id a640c23a62f3a-ace5746281emr405283666b.60.1745525098332; Thu, 24 Apr 2025 13:04:58 -0700 (PDT) Received: from localhost.localdomain ([2001:871:260:e754:5e12:787:a896:2a2e]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ace6e587f2csm14248266b.77.2025.04.24.13.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Apr 2025 13:04:57 -0700 (PDT) Message-ID: Subject: Re: Documentation correction suggestion for primary key hashing on partitioned tables From: Laurenz Albe To: mark@markandruth.co.uk, pgsql-docs@lists.postgresql.org Date: Thu, 24 Apr 2025 22:04:57 +0200 In-Reply-To: <174548810572.676.2745231019536109132@wrigleys.postgresql.org> References: <174548810572.676.2745231019536109132@wrigleys.postgresql.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2025-04-24 at 09:48 +0000, PG Doc comments form wrote: > https://www.postgresql.org/docs/current/ddl-partitioning.html / 5.12.2.3. > Limitations says: >=20 > > To create a unique or primary key constraint on a partitioned table, th= e > partition keys must not include any expressions or function calls and the > constraint's columns must include all of the partition key columns. This > limitation exists because the individual indexes making up the constraint > can only directly enforce uniqueness within their own partitions; therefo= re, > the partition structure itself must guarantee that there are not duplicat= es > in different partitions. >=20 > This seems to imply that if I have a table of primary key (a, b, c) in > b-tree index, then a partition-by-hash method would require this full set= of > columns to be used in order for the constraints to be enforcable. However > logically this should not be the case - only a hash of a prefix of the > primary key - eg (a) or (a, b) should be needed to target the same table > each time and hence get the constraint enforced. Testing this in postgres= 16 > seems to show that it does work like this.