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 1sl7LW-005KYS-BV for pgsql-general@arkaria.postgresql.org; Mon, 02 Sep 2024 13:43:55 +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 1sl7LV-00EYyn-Fj for pgsql-general@arkaria.postgresql.org; Mon, 02 Sep 2024 13:43: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 1sl7LV-00EYye-54 for pgsql-general@lists.postgresql.org; Mon, 02 Sep 2024 13:43:53 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sl7LS-000IMi-UR for pgsql-general@lists.postgresql.org; Mon, 02 Sep 2024 13:43:52 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5bf01bdaff0so3959371a12.3 for ; Mon, 02 Sep 2024 06:43:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1725284629; x=1725889429; 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=bxbnWbSbRCMn/ZhWwSlkDXn/ff5TOuNB3tzNcgNWut0=; b=LvWdtKUHxTGTTGpZ1GmAPVjRMaW4vNDHrQ1M3o6aHR9qn9e+A/79xTMdtUjSlGa57W IevAAvpuAPrMjXUKbyvHNwBPGaTMveznF86zXcsrgN/FUgF4W1ylf8NToXITYmu9PVDP QDzcmfTKk1j4Wcmdg3MwhH1lV/w+LT0lbZCbordDF/Kgl0uqIuVcdhdZG3MzSkZg4BvT iL+ZsLGMkSAmM/POKZNGxEDE2tiHtXg28j/Ryw07jF7+Rdg9g2FXDqv+flF6O1i3cJ35 ioDoXRcfpIAVDvx54N9es4KnlGpQKn1b0LwU+lUsTsx7ojusCP5Q4HvsW0FxzSsk0T7b HsJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725284629; x=1725889429; 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=bxbnWbSbRCMn/ZhWwSlkDXn/ff5TOuNB3tzNcgNWut0=; b=kJgZ/VVbY7bASFj9H7FL+ddHcy80lImn3x31h7bduu4Yd4sp51a092RLeh0tl42QsJ dYyIv0h9lPc+v5PBt3zHN83kK1h4+b8ME0U9yXMfWHRZRChIJAEBv+hHQnCm+ZqwVdIC W4MK7A6SzdhHRcwzjHeH7aqJDUtqSXBJOF9uP1fFPr4HamCAKH9G04/8mxK+9Szm233Q qDFHJGXl4vr68dw6/hs9NhoMTV1NTK2v1PotYeDoEn84HvTT0vDe5lfr3GPrTgvTb7lB hjUuZpqBthOOIonKfKUMz+NQCs+Ma2BbRS/zJ7b3cnmvt8qNif7NI4EaMmMGDahcnj1d w+3Q== X-Forwarded-Encrypted: i=1; AJvYcCWsui+MIl7MwINmBzuh06FVGBO+HaswkXk1QCXx5dKMxAd8YR3WOizaR7mI/1w1y5oAYFo5nHpy02jtKDdY@lists.postgresql.org X-Gm-Message-State: AOJu0YzOrpoiCf33raU5Jbrq9M1BprmChdUTY9Yy53NYeAyhy41q4Qmg u2YUr9w7ijhas4KMr5IP3O0iD136m2tslJwtirKxF1lor/K9WA6X1tEBj9DfEpM= X-Google-Smtp-Source: AGHT+IGgHtY2P4LrmmdleW3qe/7B+tUJOwI7n4XngJv7kdW45mgwZ2FFMtpWiYRyhW1G09tUaHvn3A== X-Received: by 2002:a05:6402:2685:b0:5c2:54a3:6b3e with SMTP id 4fb4d7f45d1cf-5c254a36d72mr3410575a12.16.1725284628802; Mon, 02 Sep 2024 06:43:48 -0700 (PDT) Received: from dynamic-pd01.res.v6.highway.a1.net ([2001:871:5e:53f4:c624:8ff4:8180:8ef6]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c226ccfeacsm5252934a12.78.2024.09.02.06.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 06:43:48 -0700 (PDT) Message-ID: Subject: Re: Partitioning and unique key From: Laurenz Albe To: veem v , pgsql-general Date: Mon, 02 Sep 2024 15:43:48 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.4 (3.52.4-1.fc40) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 2024-09-01 at 01:32 +0530, veem v wrote: > due to postgres limitations we are unable to have this unique constraint = or primary key > only on the transaction_id column, we have to include transaction_timesta= mp with it as > a composite key. So I want to understand from experts if there is any pos= sible way to > satisfy both partitioning on transaction_timestamp column and unique key = or pk just on > transaction_id only?=C2=A0 No, you cannot have both. Usually the solution is to *not* create a primary key on the partitioned ta= ble and instead create a primary key on each partition. That won't guarantee global uniqueness (and there is no way to do that), bu= t it goes a long way by ensuring that the column is unique within each partition= . Yours, Laurenz Albe