MCPcopy Index your code
hub / github.com/wger-project/wger / count

Method count

wger/nutrition/managers.py:40–52  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

38 """
39
40 def count(self):
41 if self.query.where:
42 return super(ApproximateCountQuerySet, self).count()
43
44 if is_postgres_db() and not settings.TESTING:
45 cursor = connections[self.db].cursor()
46 cursor.execute(
47 "SELECT reltuples FROM pg_class WHERE relname = '%s';" % self.model._meta.db_table
48 )
49
50 return int(cursor.fetchone()[0])
51
52 return super(ApproximateCountQuerySet, self).count()
53
54
55ApproximateCountManager = Manager.from_queryset(ApproximateCountQuerySet)

Calls 1

is_postgres_dbFunction · 0.90