Обсуждение: [ADMIN] Partitions
Hi,
I have a requirement to create monthly partitions in my db, i am trying to understand what is the best way to do it, i know i can run a cron job to check if partition exist and create if not at the starting of month. Any suggestions?
Thanks,
Ram
Set up a trigger on insert to check for the existence of the partition table, then it could do the insert there or createthe table if needed and insert. Look online. I know I’ve seen examples of this. — Jay Sent from my iPad > On Nov 9, 2017, at 6:28 PM, rammohan ganapavarapu <rammohanganap@gmail.com> wrote: > > Hi, > > I have a requirement to create monthly partitions in my db, i am trying to understand what is the best way to do it, iknow i can run a cron job to check if partition exist and create if not at the starting of month. Any suggestions? > > Thanks, > Ram -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin
Greetings, * rammohan ganapavarapu (rammohanganap@gmail.com) wrote: > I have a requirement to create monthly partitions in my db, i am trying to > understand what is the best way to do it, i know i can run a cron job to > check if partition exist and create if not at the starting of month. Any > suggestions? I'd suggest you take a look at pg_partman. Thanks! Stephen
I saw pg_parman but it's third party extension right, i am trying to see if I can use native plugin or extension to the job.
Thanks for your suggestion, i will consider it.
Ram
On Nov 9, 2017 4:18 PM, "Stephen Frost" <sfrost@snowman.net> wrote:
Greetings,
* rammohan ganapavarapu (rammohanganap@gmail.com) wrote:
> I have a requirement to create monthly partitions in my db, i am trying to
> understand what is the best way to do it, i know i can run a cron job to
> check if partition exist and create if not at the starting of month. Any
> suggestions?
I'd suggest you take a look at pg_partman.
Thanks!
Stephen
Greetings, * rammohan ganapavarapu (rammohanganap@gmail.com) wrote: > I saw pg_parman but it's third party extension right, i am trying to see if > I can use native plugin or extension to the job. There isn't anything built-in, which means the options are to build your own version of something like pg_partman, or to simply use pg_partman. You're certainly welcome to choose between those, but I can say that I'm pretty happy to use pg_partman to deal with exactly what you're asking for. Thanks! Stephen
Thank you, i will take a look.
Ram
On Thu, Nov 9, 2017 at 5:50 PM, Stephen Frost <sfrost@snowman.net> wrote:
Greetings,
* rammohan ganapavarapu (rammohanganap@gmail.com) wrote:
> I saw pg_parman but it's third party extension right, i am trying to see if
> I can use native plugin or extension to the job.
There isn't anything built-in, which means the options are to build your
own version of something like pg_partman, or to simply use pg_partman.
You're certainly welcome to choose between those, but I can say that I'm
pretty happy to use pg_partman to deal with exactly what you're asking
for.
Thanks!
Stephen
> On Nov 9, 2017, at 18:41, John Scalia <jayknowsunix@gmail.com> wrote: > > Set up a trigger on insert to check for the existence of the partition table, then it could do the insert there or createthe table if needed and insert. Look online. I know I’ve seen examples of this. Be careful here, these solutions generally take a massive performance hit. The best method is the native pg_partman function.It includes a built-in scheduler so that you don’t need to rely on an external tool like cron. > — > Jay > > Sent from my iPad > >> On Nov 9, 2017, at 6:28 PM, rammohan ganapavarapu <rammohanganap@gmail.com> wrote: >> >> Hi, >> >> I have a requirement to create monthly partitions in my db, i am trying to understand what is the best way to do it, iknow i can run a cron job to check if partition exist and create if not at the starting of month. Any suggestions? >> >> Thanks, >> Ram > > > -- > 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