Re: Partitioning by month causing an error?

Поиск
Список
Период
Сортировка
От Wells Oliver
Тема Re: Partitioning by month causing an error?
Дата
Msg-id CAOC+FBWOs321LCj6Rxe8-==Q4So2XcNSf3eJ0KzTT3q2eHUnpA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Partitioning by month causing an error?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Partitioning by month causing an error?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-admin
This is really interesting to me: why? Running select '2019-04-30'::date between '2019-04-01'::date and '2019-04-30'::date; yields true, and generally the lower and upper bounds are inclusive in any kind of between check for languages I am familiar with.

Appreciate the answer, just curious. Thanks as always Tom.

On Fri, Dec 20, 2019 at 6:59 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Wells Oliver <wells.oliver@gmail.com> writes:
> I have a partition per each month, like this:
> CREATE TABLE mmd_yr2019_3 PARTITION OF mmd FOR VALUES FROM ('2019-03-01')
> TO ('2019-03-31');
> CREATE TABLE mmd_yr2019_4 PARTITION OF mmd FOR VALUES FROM ('2019-04-01')
> TO ('2019-04-30');

> This breaks for dates at the end of the month. What's the better way to
> write the bounds? 3/1 to 4/1 and then 4/1 to 5/1? Does that cause some
> overlap issue?

The rule is that a range partition from A to B covers values A <= X < B.
So you should be using first-of-the-month dates for all of these
values.  As you have it, there's gaps in the allowable values,
totally aside from the PITA factor of having to identify the last
day of each month accurately.

                        regards, tom lane


--

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

Предыдущее
От: Ron
Дата:
Сообщение: Re: Partitioning by month causing an error?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Partitioning by month causing an error?