Skip to content

Instantly share code, notes, and snippets.

@jorgemanrubia
Created April 22, 2021 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgemanrubia/8cd8e8f80d0c08f26e341979fb910a37 to your computer and use it in GitHub Desktop.
Save jorgemanrubia/8cd8e8f80d0c08f26e341979fb910a37 to your computer and use it in GitHub Desktop.
Estimated count from table stats (MySQL)
def count_from_table_stats(klass)
result = klass.connection.execute("show table status like '#{klass.table_name}'")
result.first[result.fields.index("Rows")]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment