How to clean up the trends and trend_counters tables inside the foreman database on Red Hat Satellite 6?
Environment
- Red Hat Satellite 6.x
Issue
- Using the script attached to Postgresql database is growing and disk space utilization of /var/lib/pgsql is increasing in Red Hat Satellite 6, the
trendsandtrend_counterstables inside theforemandatabase were identified among the largest tables.
Resolution
-
If the trends or the trend_counters table inside the foreman database is consuming too much space and requires cleanup, then follow the steps as instructed below:
-
Check the current count of records in both tables:
# su - postgres -c "psql -d foreman -c 'select count(*) as count from trends;'" # su - postgres -c "psql -d foreman -c 'select count(*) as count from trend_counters;'" -
To reduce the number of records, use the following command:
# foreman-rake trends:reduce --trace --verbose -
Verify the current count of records:
# su - postgres -c "psql -d foreman -c 'select count(*) as count from trends;'" # su - postgres -c "psql -d foreman -c 'select count(*) as count from trend_counters;'" -
If the command in step (2) did not help, then deletion can be attempted via the following command:
# cat << FIX | foreman-rake console interval_end = TrendCounter.arel_table[:interval_end] TrendCounter.where(interval_end.lt(30.days.ago)).delete_all FIX
-
For more KB articles/solutions related to Red Hat Satellite 6.x PostgreSQL-related Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x PostgreSQL-related Issues
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.