Postgres 9.1 - I have a schema that has tables "partitioned" by month (a new table is created each month, all columns the same). It is not set up as normal partitioning with a "master" table. I am currently writing a fairly large query, that I will have to run a few times each month.
Schema: augmented_events
tables:
p201301
(January 2013)
p201302
(Feb 2013)
p201303
(March 2013)
...
p201312
(December 2013)
p201401
(January 2014)
Right now I have to write my (simplified) query as:
select *
from augmented_events.p201301
union
select *
from augmented_events.p201302
union
select *
from augmented_events.p201303
union
select *
from augmented_events.p201312
union
select *
from augmented_events.p201401
And every month I need to add in the new month. I would like to make this a little more scalable without me having to revisit it every month. Is there a function I can create (or one that exists) that loops through each table in the augmented_events
schema, and treats it as if I was to union these tables?