Re: Question on Partition key

Поиск
Список
Период
Сортировка
От Erik Wienhold
Тема Re: Question on Partition key
Дата
Msg-id 430765976.88455.1693698631044@office.mailbox.org
обсуждение исходный текст
Ответ на Question on Partition key  (veem v <veema0000@gmail.com>)
Ответы Re: Question on Partition key  (Deep <biswachk@gmail.com>)
Список pgsql-general
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



В списке pgsql-general по дате отправления:

Предыдущее
От: veem v
Дата:
Сообщение: Question on Partition key
Следующее
От: Deep
Дата:
Сообщение: Re: Question on Partition key