Created
April 22, 2021 14:41
-
-
Save jorgemanrubia/8cd8e8f80d0c08f26e341979fb910a37 to your computer and use it in GitHub Desktop.
Estimated count from table stats (MySQL)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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