Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHwNe-0004h7-C6 for pgsql-general@arkaria.postgresql.org; Tue, 08 Oct 2019 20:46:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iHwNb-0006i1-MX for pgsql-general@arkaria.postgresql.org; Tue, 08 Oct 2019 20:46:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHwNb-0006hu-9t for pgsql-general@lists.postgresql.org; Tue, 08 Oct 2019 20:46:47 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHwNU-0001WS-Lf for pgsql-general@lists.postgresql.org; Tue, 08 Oct 2019 20:46:46 +0000 Received: by mail-oi1-x234.google.com with SMTP id o205so16017469oib.12 for ; Tue, 08 Oct 2019 13:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=jhjHYH+2/fcXIA71i3QZQaaWy+D75c0fIEpBpREyfrg=; b=cfSKK6MZZ5pVrQJOj6Zkfpy1y7Uj4Go8T9z0VnuybZJuyIwidoX0NL+EMGlDZtMJPo hK4mPpuAA03LNo4Qbl8ILUPoSeUSM8XOv+PojxHGLpT+ED3CgEEsz1MbfN1x2V1uQMC6 0F6Lojv+DGmd0DlYhdT7lneOZLIjiNhdj4jY/39cQjJjYTok+mCxFsDYyHOUQN95EJ2i jgf084Q8CgzuWeniwAaYaYaNuNBTnRnS3yqtfU9Gdst2v+GS/6vDMgT/yD2qU3vVZYLf KXN2OEKbPwB55AZ6U4eAkeMhaw9E15XsLDwdD1qusj2X2ep4Yui+LXe1DZazZ035LMjV +2Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=jhjHYH+2/fcXIA71i3QZQaaWy+D75c0fIEpBpREyfrg=; b=apsZndB/p/GaydYOx30pDXPTCo56Cp/f2u2FdNvpaFTX4EqtySN8cGa5rJSkH16bsu bAZzGGvS37zJ79ztnpA3vff+tZOnQZ2L+dsAbrRYb16nW9dU0aCKck3fVQRK2iRWWpXX s/cAx+T5x/jTEHX+nOxdOdJCXc24TQ4PibWdcgcaT5MOYZfJpK+gi9d9U1JkTonH6IZu b975c+M6ZlnBzC8dB8/n4k7XxEuGm/XPWRT9VogKOZSMKA9BzwuRr39q+se8TKlYxAaH pqvyailOkyLarcmClmRGdJQbyI5sLHEdOhDs1G1vFgd5JyUfps2HOTDyPQJP5U8BSiOJ i7gw== X-Gm-Message-State: APjAAAX7Fwcekyd5+yWIpNmAdcfApiL51gD5BqFgB3t33jjdL3lAgoq5 jixfTFwYJxxEMQRjUBu6ki2TY0ptXnyiHA== X-Google-Smtp-Source: APXvYqyI8xxxN0+c9XOgtWzOV3n60XtnspcAiWLLkANl2p5EW4tGx19wgSOuai3N0UWaPzIiRshBBg== X-Received: by 2002:aca:6084:: with SMTP id u126mr5488465oib.163.1570567598054; Tue, 08 Oct 2019 13:46:38 -0700 (PDT) Received: from [192.168.1.10] (ip70-186-126-197.no.no.cox.net. [70.186.126.197]) by smtp.googlemail.com with ESMTPSA id a9sm5869972otc.75.2019.10.08.13.46.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 13:46:37 -0700 (PDT) Subject: Re: Declarative Range Partitioning Postgres 11 To: pgsql-general@lists.postgresql.org References: From: Ron Message-ID: Date: Tue, 8 Oct 2019 15:46:36 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------7A421E6FDC210A99BEF7B03B" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------7A421E6FDC210A99BEF7B03B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 10/8/19 12:33 PM, Michael Lewis wrote: > On Tue, Oct 8, 2019 at 8:00 AM Shatamjeev Dewan > wrote: > > Hi Michael, > > In this case , I always need to include partition key(date)  in > primary key ( if I have a primary key defined on non partition key > column e.g id (in my case), to make it a composite primary key (id, > date). This would allow duplicate id with different date,which is not > desirable . > > > If you are generating the ID with a sequence, there isn't any real world > likelihood of conflict, but I do understand your concern in terms of > enforcing data integrity. Other than creating a custom stored procedure > that functions as a primary key constraint, I don't know of any way around > that. > > Let's take a step back... why do you think you need to partition at all? > And why partition by the date/timestamp/timestamptz field? Because archiving old is (well, /should be/) easier that way. -- Angular momentum makes the world go 'round. --------------7A421E6FDC210A99BEF7B03B Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 10/8/19 12:33 PM, Michael Lewis wrote:
On Tue, Oct 8, 2019 at 8:00 AM Shatamjeev Dewan <sdewan@nbsps.com> wrote:

Hi Michael,

 

In this case , I always need to include partition key(date)  in primary key ( if I have a primary key defined on non partition key column e.g id (in my case), to make it a composite primary key (id, date). This would allow duplicate id with different date,which is not desirable .


If you are generating the ID with a sequence, there isn't any real world likelihood of conflict, but I do understand your concern in terms of enforcing data integrity. Other than creating a custom stored procedure that functions as a primary key constraint, I don't know of any way around that.

Let's take a step back... why do you think you need to partition at all? And why partition by the date/timestamp/timestamptz field?

Because archiving old is (well, should be) easier that way.

--
Angular momentum makes the world go 'round.
--------------7A421E6FDC210A99BEF7B03B--