Echftp Auto Part
Echftp Auto Part
Automating
Partition Creation and Deletion Procedure
####################################################
Purpose: This document outlines the systematic procedure for configuring auto-
creation and deletion of partitions in your PostgreSQL database environment.
Step 1: Create Configuration Table #Skip this step if it already exist for
routing_entity_log
--------------------------
psql> \c config
mkdir -p /tmp/pdump
--Connect with Config DB and execute below:
-- Grant connection privilege to the database
GRANT CONNECT ON DATABASE config TO dbadmin;
Step 5: Schedule Job in Crontab (This will execute daily at 9PM, change as per
requirement)
-----------------------
a) Create directory for logs
mkdir -p /data/scripts/part_log
0 1 * * * /data/scripts/auto_part.sh >>
/data/scripts/part_log/auto_part_$(date +\%Y\%m\%d).log 2>&1
0 2 * * * find /data/scripts/part_log -name "*.log" -type f -mtime +15
-exec rm -f {} \;
OR
\d+ routing_entity_log
d) Verification of routing_entity_log
SELECT c.oid::regclass AS child_partition,
p.oid::regclass AS parent_tbl,
pg_get_expr(c.relpartbound, c.oid) AS boundaries
FROM pg_class AS p
JOIN pg_inherits AS i ON p.oid = i.inhparent
JOIN pg_class AS c ON i.inhrelid = c.oid
WHERE p.relkind = 'p';
OR
\d+ routing_entity_log
Step 14: Schedule Job in Crontab (This will execute daily at 9PM, change as per
requirement)
-----------------------
a) Execute the auto_part job manually from OS, it will create today and
future partitions
sh /data/scripts/auto_part.sh >>
/data/scripts/part_log/auto_part_log_$(date +\%Y\%m\%d).log 2>>
/data/scripts/part_log/auto_part_log_$(date +\%Y\%m\%d).err