Quantcast
Channel: User Schwern - Stack Overflow
Viewing all articles
Browse latest Browse all 581

Answer by Schwern for How to find the size of a table in bytes in Ruby on Rails?

$
0
0

There's little benefit to putting it in the application which is using the database, it just complicates the application. Usually this information would be monitored by a tool outside the application.

Heroku already provides metrics for PostgreSQL and will alert you when the database is getting too large and gives you a 7 day grace period.

  1. When an Essential database reaches 90% of a usage limit, the owner receives a warning email.
  2. When the database exceeds a plan limit, the owner receives an additional notification. At this point, the database receives a 7-day grace period to comply with the limit or migrate to another plan. If your database is over 200% of the plan limit at any time, we skip the grace period and immediately revoke access.

You can ask Heroku to set additional alerts.

Set alerts based on your plans limit to give you some advanced notice if you start approaching it. We recommend setting a warning alert when your database gets to 80% of the allotted size for your plan and a critical alert when it gets to 90% of the allotted size.


Your Heroku application logs already contain database metrics, including the database size.

For more fine-grained information, start with the heroku-pg-extras extension to the Heroku CLI. From there you can get information about how your database is growing, and suggestions about where you could trim some bloat.

  • pg:index-usage, pg:unused-indexes, and pg:index-size can help find large, unused indexes which could be dropped to save space and time.
  • pg:table-size can monitor your table growth.
  • pg:bloat and pg:vacuum-stats can tell you if your auto-vacuum needs tuning.

And there are other techniques for controlling database growth: periodically dropping old data (made efficient using table partitions); moving data not needed for runtime into a data warehouse, for example business intelligence and other statistical data.


See Heroku Postgres Monitoring Best Practices and Heroku Monitoring and Metrics for more.


Viewing all articles
Browse latest Browse all 581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>