pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: iterate over partitions
Date: Mon, 1 Jul 2019 10:12:51 +0300
Message-ID: <b09b2fb2-ab1e-8708-4616-f4d2cc15654a@matrix.gatewaynet.com> (raw)
In-Reply-To: <CAE-4=KHcn8cL+o7HVzF2pYiamynodQPB=OG2LGnt7JUqVgzXFQ@mail.gmail.com>
References: <CAE-4=KHcn8cL+o7HVzF2pYiamynodQPB=OG2LGnt7JUqVgzXFQ@mail.gmail.com>

On 28/6/19 10:11 μ.μ., Glenn Schultz wrote:
> Hi All,
>
> I have a large table partioned by month.  I would like to run a query - which adds derived data to the current data and inserts the data into a new table.  The new table is the target for users.
>
> How can I iterate over the partition tables to insert data and build the new table?
> This is done monthly, am I better off creating a materalized view each month?
Well not using partitions yet in production, I can't say I can fully grasp your use case, but anyways, in order to iterate over partitions you'll have to look at : pg_partitioned_table , pg_inherits 
or just enable log_statement , issue \d+ <your partitioned table> and look at the SQL produced.
Or just do :
select inhrelid::regclass from pg_inherits where inhparent = 'your partitioned table'::regclass;

>
> Best,
> Glenn


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt






view thread (2+ messages)

Message-ID: <b09b2fb2-ab1e-8708-4616-f4d2cc15654a@matrix.gatewaynet.com>
Permalink:  ../b09b2fb2-ab1e-8708-4616-f4d2cc15654a@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/b09b2fb2-ab1e-8708-4616-f4d2cc15654a@matrix.gatewaynet.com

 · 

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: achill@matrix.gatewaynet.com
  Subject: Re: iterate over partitions
  In-Reply-To: <b09b2fb2-ab1e-8708-4616-f4d2cc15654a@matrix.gatewaynet.com>
  References: <CAE-4=KHcn8cL+o7HVzF2pYiamynodQPB=OG2LGnt7JUqVgzXFQ@mail.gmail.com> <b09b2fb2-ab1e-8708-4616-f4d2cc15654a@matrix.gatewaynet.com>

* 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