mirror of
https://github.com/quay/quay.git
synced 2026-01-26 06:21:37 +03:00
- Change the counts to use the MySQL information schema for estimates - Change the lookup of active users to skip the unnecessary heavy filter
12 lines
502 B
Python
12 lines
502 B
Python
def mysql_estimate_row_count(model_cls, db):
|
|
""" Uses the information_schema to retrieve the row count for a table. """
|
|
query = "SELECT table_rows FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = %s"
|
|
cursor = db.execute_sql(query, (model_cls._meta.table_name,))
|
|
res = cursor.fetchone()
|
|
return res[0]
|
|
|
|
|
|
def normal_row_count(model_cls, db):
|
|
""" Uses a normal .count() to retrieve the row count for a model. """
|
|
return model_cls.select().count()
|