sql - Automatically dropping PostgreSQL tables once per day -


i have scenario have central server , node. both server , node capable of running postgresql storage space on node limited. node collects data @ high speed , writes data local db. server needs replicate data node. plan on accomplishing slony-i or bucardo. node needs able delete records tables @ set interval in order minimize disk space used. should use pgagent job consisting of script

delete tablex, tabley, tablez; 

where actual batch file run script like

@echo off c:\progra~1\postgresql\9.1\bin\psql -d database -h localhost -p 5432 -u postgres -f c:\deletefrom.sql 

?

i'm looking opinions if best way accomplish task or if knows of more efficient way pull data remote db , clear remote db save space on remote node. time.

the efficient command truncate command.

with truncate, can chain tables, example:

truncate tablex, tabley, tablez; 

here's description postgres docs:

truncate removes rows set of tables. has same effect unqualified delete on each table, since not scan tables faster. furthermore, reclaims disk space immediately, rather requiring subsequent vacuum operation. useful on large tables.

you may add cascade parameter:

cascade automatically truncate tables have foreign-key references of named tables, or tables added group due cascade.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -