pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Partition DB Tables by month
7+ messages / 3 participants
[nested] [flat]

* Partition DB Tables by month
@ 2003-07-29 00:12 Romildo Wildgrube <romildo@ragingnet.com>
  2003-07-29 11:47 ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  0 siblings, 1 reply; 7+ messages in thread

From: Romildo Wildgrube @ 2003-07-29 00:12 UTC (permalink / raw)
  To: pgsql-admin

Hi,

Is there a way to break the data files by month like in Oracle so that I 
can easely drop the tables on a monthly basis? Is this something 
postgres supports or is there a work around solution?

Any help will be much appreciated.

Romi




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Partition DB Tables by month
  2003-07-29 00:12 Partition DB Tables by month Romildo Wildgrube <romildo@ragingnet.com>
@ 2003-07-29 11:47 ` Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-29 14:05   ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  0 siblings, 1 reply; 7+ messages in thread

From: Dani Oderbolz @ 2003-07-29 11:47 UTC (permalink / raw)
  To: Romildo Wildgrube <romildo@ragingnet.com>; +Cc: pgsql-admin

Romildo Wildgrube wrote:

> Hi,
>
> Is there a way to break the data files by month like in Oracle so that 
> I can easely drop the tables on a monthly basis? Is this something 
> postgres supports or is there a work around solution? 

Hmm, as far as I know its not supported.
But I could think of a solution of a table per month
which are then hidden behind a view which does a UNION ALL
on all of them.
You could even automate the Adminostration of this via a Function.
I mean, in Oracle Partitions behave like single tables, so this would
simulate somethig similar.
But I think the Optimizer would not
be able to see that he must only access the table table_Jan_2003
if you are restricting on January 2003...

Cheers, Dani





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Partition DB Tables by month
  2003-07-29 00:12 Partition DB Tables by month Romildo Wildgrube <romildo@ragingnet.com>
  2003-07-29 11:47 ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
@ 2003-07-29 14:05   ` Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-29 23:53     ` Re: Partition DB Tables by month Mendola Gaetano <mendola@bigfoot.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Dani Oderbolz @ 2003-07-29 14:05 UTC (permalink / raw)
  To: Ray Ontko <rayo@ontko.com>; pgsql-admin

Ray Ontko wrote:

>One limitation to the UNION approach is that you can't 
>insert, update, or delete through the UNION view.  At
>some point the application needs to understand how the
>virtual table is partitioned into these month-specific
>tables.
>
>Romido: Why not simply delete the rows each month instead
>of dropping tables each month?
>
Hmm,
but it wouls surely be possible (at the cost of some performace)
to put a trigger on the view to actually sort this all out.
I guess deleting is a really bad option, as
1. The DB needs to do all kinds of logging which you donmm't want (you 
dont want to rollback ever)
2. This operations leaves you with a big Vacuum job

Therefore, I think, Partitioning could be a good thing.
BDW: This might be a really important reason for a
company to switch their Data Warehouse to Postgres,
as this is almost impossible without it.


Regards,
Dani




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Partition DB Tables by month
  2003-07-29 00:12 Partition DB Tables by month Romildo Wildgrube <romildo@ragingnet.com>
  2003-07-29 11:47 ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-29 14:05   ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
@ 2003-07-29 23:53     ` Mendola Gaetano <mendola@bigfoot.com>
  2003-07-30 10:00       ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  0 siblings, 1 reply; 7+ messages in thread

From: Mendola Gaetano @ 2003-07-29 23:53 UTC (permalink / raw)
  To: pgsql-admin; +Cc: Dani Oderbolz <oderbolz@ecologic.de>

"Dani Oderbolz" <oderbolz@ecologic.de> wrote:
> Ray Ontko wrote:
> 
> >One limitation to the UNION approach is that you can't 
> >insert, update, or delete through the UNION view.  At
> >some point the application needs to understand how the
> >virtual table is partitioned into these month-specific
> >tables.
> >
> >Romido: Why not simply delete the rows each month instead
> >of dropping tables each month?
> >
> Hmm,
> but it wouls surely be possible (at the cost of some performace)
> to put a trigger on the view to actually sort this all out.
> I guess deleting is a really bad option, as
> 1. The DB needs to do all kinds of logging which you donmm't want (you 
> dont want to rollback ever)
> 2. This operations leaves you with a big Vacuum job
> 
> Therefore, I think, Partitioning could be a good thing.
> BDW: This might be a really important reason for a
> company to switch their Data Warehouse to Postgres,
> as this is almost impossible without it.

If the goal is have the query optimized for the last month
you can easilly accomplish this using a partial index.


Regards
Gaetano Mendola




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Partition DB Tables by month
  2003-07-29 00:12 Partition DB Tables by month Romildo Wildgrube <romildo@ragingnet.com>
  2003-07-29 11:47 ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-29 14:05   ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-29 23:53     ` Re: Partition DB Tables by month Mendola Gaetano <mendola@bigfoot.com>
@ 2003-07-30 10:00       ` Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-30 15:00         ` Re: Partition DB Tables by month Mendola Gaetano <mendola@bigfoot.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Dani Oderbolz @ 2003-07-30 10:00 UTC (permalink / raw)
  To: Mendola Gaetano <mendola@bigfoot.com>; +Cc: pgsql-admin

Mendola Gaetano wrote:

>you can easilly accomplish this using a partial index.
>  
>
Would that really work with a view?
Can you post a syntax example for this?

Regards,
Dani




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Partition DB Tables by month
  2003-07-29 00:12 Partition DB Tables by month Romildo Wildgrube <romildo@ragingnet.com>
  2003-07-29 11:47 ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-29 14:05   ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-29 23:53     ` Re: Partition DB Tables by month Mendola Gaetano <mendola@bigfoot.com>
  2003-07-30 10:00       ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
@ 2003-07-30 15:00         ` Mendola Gaetano <mendola@bigfoot.com>
  2003-07-30 16:17           ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  0 siblings, 1 reply; 7+ messages in thread

From: Mendola Gaetano @ 2003-07-30 15:00 UTC (permalink / raw)
  To: pgsql-admin; +Cc: Dani Oderbolz <oderbolz@ecologic.de>

"Dani Oderbolz" <oderbolz@ecologic.de> wrote:
> Mendola Gaetano wrote:
>
> >you can easilly accomplish this using a partial index.
> >
> >
> Would that really work with a view?
> Can you post a syntax example for this?

CREATE TABLE foo (
field_a
field_b
......
fast_search  BOOLEAN NOT NULL DEFAULT 1,
time_stamp TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX idx_fast_search ON foo ( fast_search ) where fast_search = 't';

for each field to index:
CREATE INDEX idx_field_a ON foo ( field_a ) where fast_search = 't';
CREATE INDEX idx_field_b ON foo ( field_b ) where fast_search = 't';


at the beginning of each month you can now do:

UPDATE foo SET fast_search = 'f'
WHERE time_stamp < now() AND
fast_search = 't';


Your improved query for the last month:

SELECT *
FROM foo
WHERE fast_search = 't' AND
    <field_a> = XXXXX AND
   <field_b> = YYYYYY;


I hope this help


Regards
Gaetano
























^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Partition DB Tables by month
  2003-07-29 00:12 Partition DB Tables by month Romildo Wildgrube <romildo@ragingnet.com>
  2003-07-29 11:47 ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-29 14:05   ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-29 23:53     ` Re: Partition DB Tables by month Mendola Gaetano <mendola@bigfoot.com>
  2003-07-30 10:00       ` Re: Partition DB Tables by month Dani Oderbolz <oderbolz@ecologic.de>
  2003-07-30 15:00         ` Re: Partition DB Tables by month Mendola Gaetano <mendola@bigfoot.com>
@ 2003-07-30 16:17           ` Dani Oderbolz <oderbolz@ecologic.de>
  0 siblings, 0 replies; 7+ messages in thread

From: Dani Oderbolz @ 2003-07-30 16:17 UTC (permalink / raw)
  To: Mendola Gaetano <mendola@bigfoot.com>; +Cc: pgsql-admin

Mendola Gaetano wrote:

> CREATE TABLE foo (field_a
>
>field_b
>......
>fast_search  BOOLEAN NOT NULL DEFAULT 1,
>time_stamp TIMESTAMPTZ NOT NULL DEFAULT now()
>);
>CREATE INDEX idx_fast_search ON foo ( fast_search ) where fast_search = 't';
>
>for each field to index:
>CREATE INDEX idx_field_a ON foo ( field_a ) where fast_search = 't';
>CREATE INDEX idx_field_b ON foo ( field_b ) where fast_search = 't';
>
>
>at the beginning of each month you can now do:
>
>UPDATE foo SET fast_search = 'f'
>WHERE time_stamp < now() AND
>fast_search = 't';
>  
>
I guess we are missunderstanding each other.
I meant you were saying that you could have a partial index on a view
which does a Union All of may tables (each table contains a Month).
But I think thats really not possible.

Cheers,
Dani




^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2003-07-30 16:17 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-29 00:12 Partition DB Tables by month Romildo Wildgrube <romildo@ragingnet.com>
2003-07-29 11:47 ` Dani Oderbolz <oderbolz@ecologic.de>
2003-07-29 14:05   ` Dani Oderbolz <oderbolz@ecologic.de>
2003-07-29 23:53     ` Mendola Gaetano <mendola@bigfoot.com>
2003-07-30 10:00       ` Dani Oderbolz <oderbolz@ecologic.de>
2003-07-30 15:00         ` Mendola Gaetano <mendola@bigfoot.com>
2003-07-30 16:17           ` Dani Oderbolz <oderbolz@ecologic.de>

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