From: Haifeng Liu <liuhaifeng@live.com>
To: Sergey Konoplev <gray.ru@gmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Daily Rotated Insertion
Date: Tue, 27 Mar 2012 18:05:56 +0800
Message-ID: <BLU0-SMTP2145D8DE7E99BCAB06AB71DB94A0@phx.gbl> (raw)
In-Reply-To: <CAL_0b1v0r16GzUER+V_jJo+Z9ySxtPZHCqzmM0rTXv3btM0_oA@mail.gmail.com>
References: <BLU0-SMTP195BAAB8B6E63CE73CF5849B9450@phx.gbl>
<CAL_0b1sTAbkyUQUzKfnY6+yHQqSgZ9JVbBV6HH6KC6tu6zH5fA@mail.gmail.com>
<BLU0-SMTP4434590A1672562321D21ACB94A0@phx.gbl>
<CAL_0b1v0r16GzUER+V_jJo+Z9ySxtPZHCqzmM0rTXv3btM0_oA@mail.gmail.com>
On Mar 27, 2012, at 3:33 PM, Sergey Konoplev wrote:
> On Tue, Mar 27, 2012 at 10:02 AM, Haifeng Liu <liuhaifeng@live.com> wrote:
>> Yes, that's what I am doing. There are many ways to implement partitioned table, I just want to find an elegant one. Bulk create a certain number of partitions is not good in my opinion. What I am trying now is let the trigger which switches insertions to catch exceptions and create new partitions on demand, meanwhile. update the trigger itself to use the new switch rule.
>>
>> This idea can use static statement to switch insertions, dynamic statements are only used to create partition and update the trigger, this should be good for performance. And compare to the static partition example given in the document, this solution can auto-update itself, there is no need for cron jobs to maintenance partition.
>
> Okay, I got what you mean. I used to use auto partitioning in one of
> my projects but it assumed errors catching on the application server
> side. However you can easily adapt the solution for your needs. I
> attached the script to the message.
>
> BTW, I created it several years ago. A lot of nice stuff like CREATE
> TABLE IF NOT EXISTS were added in the new versions of PostgreSQL. So I
> think may be you could get rid of catching exceptions completely with
> help of these new features.
>
> Please let me know if you decide to use this approach and modify it.
Thanks for sharing your script. Mine is done now, my goal is make the trigger more simple for most case, so I use a function to create trigger function and make the redirect rule static, and if an exception occurred when new DATE is found, the trigger will call the function to recreate itself.
Main ddls of my solution is posted as attachment.=
>
>>
>> I am not sure if this idea work, still trying now.
>>
>>>
>>>>
>>>> Any idea is appreciated. Thanks in advance.
>>>>
>>>>
>>>> Best regards.
>>>> liuhaifeng
>>>> --
>>>> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
>>>> To make changes to your subscription:
>>>> http://www.postgresql.org/mailpref/pgsql-admin
>>>
>>>
>>>
>>> --
>>> Sergey Konoplev
>>>
>>> Blog: http://gray-hemp.blogspot.com
>>> LinkedIn: http://ru.linkedin.com/in/grayhemp
>>> JID/GTalk: gray.ru@gmail.com Skype: gray-hemp
>>>
>>> --
>>> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgsql-admin
>>>
>>
>>
>> --
>> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-admin
>
>
>
> --
> Sergey Konoplev
>
> Blog: http://gray-hemp.blogspot.com
> LinkedIn: http://ru.linkedin.com/in/grayhemp
> JID/GTalk: gray.ru@gmail.com Skype: gray-hemp
> <auto_partitioning.sql>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-adminAttachments:
auto-partition.sql (application/octet-stream, 2.9K) download
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 using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: liuhaifeng@live.com, gray.ru@gmail.com
Subject: Re: Daily Rotated Insertion
In-Reply-To: <BLU0-SMTP2145D8DE7E99BCAB06AB71DB94A0@phx.gbl>
* 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