RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

fast_count - a new gem to quickly get an accurate count estimation for large tables

I released a new gem - https://github.com/fatkodima/fast_count

It allows to get an accurate count estimation (ยป99% accuracy for PostgreSQL) for large tables in a blink of an eye (compared to SELECT COUNT(*), which can literally take tens of minutes or hours to compute).

Note that while it also supports MySQL, there is no way to accurately estimate a count of rows in the MySQL (InnoDB) table all the time yet, so it can vary from the actual value by as much as 50%. But still is useful to get a rough idea of the number of rows in very large tables.

Getting count of rows in the tables is very often useful in the admin sections of the site, for reporting, some growth predictions, capacity or some operation times estimations, etc.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in