pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Wienhold <ewie@ewie.name>
To: veem v <veema0000@gmail.com>
To: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Question on Partition key
Date: Sun, 3 Sep 2023 01:50:31 +0200 (CEST)
Message-ID: <430765976.88455.1693698631044@office.mailbox.org> (raw)
In-Reply-To: <CAB+=1TWUHxm1o9s6NVfw74L1n155gw4zyCfSCUKTTkWwAHE_2Q@mail.gmail.com>
References: <CAB+=1TWUHxm1o9s6NVfw74L1n155gw4zyCfSCUKTTkWwAHE_2Q@mail.gmail.com>

On 03/09/2023 00:35 CEST veem v <veema0000@gmail.com> wrote:

> We are trying to create a monthly range partition table , partitioned on
> column PART_DATE. This will hold Orders and part_date is nothing but invoice
> date. Some Team mates are asking to use the "PART_DATE" column as data type
> "INTEGER" with "YYYYMM" format [...]

Why do your team mates favor integer over date?

> Want to know experts' views on this. If the data type of the partition key
> matters here or not?

Both integer and date are stored as 4 bytes.  There should be no difference
regarding index size.  I don't know if the data type makes a difference in
partition pruning performance in this case, but I'd be surprised if it were
the case.

> Or if there is any downside of each approach in future?

The downside of integer is that it allows invalid dates (e.g. 202313) unless
you also add check constraints.  But then just use date if you want to store
dates.  You get input validation and can use the date operators and functions
that Postgres offers.

--
Erik





view thread (5+ messages)  latest in thread

Message-ID: <430765976.88455.1693698631044@office.mailbox.org>
Permalink:  ../430765976.88455.1693698631044@office.mailbox.org/
Also on:    postgresql.org/message-id/430765976.88455.1693698631044@office.mailbox.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ewie@ewie.name, veema0000@gmail.com
  Subject: Re: Question on Partition key
  In-Reply-To: <430765976.88455.1693698631044@office.mailbox.org>
  References: <CAB+=1TWUHxm1o9s6NVfw74L1n155gw4zyCfSCUKTTkWwAHE_2Q@mail.gmail.com> <430765976.88455.1693698631044@office.mailbox.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox