Often, a database can contain several unused objects or very old data. Cleaning up these objects helps administrators perform a backup of images more quickly. From a development point of view, unused objects are noise because they affect the refactoring process.
In database applications, one needs to keep the database clean as unused database objects might hinder quick development due to those objects' dependencies. To clean the database, one needs to identify the unused database objects, including tables, views, indexes, and functions.Â
Table statistics, such as the number of live rows, index scans, and sequential scans, can help identify empty and unused tables. Note that the following queries are based on statistics, so the results need to be validated. The pg_stat_user_tables table provides this information, and the following query shows...