(self)
return int(row[0])
Fast approximate count of all model instances

        PostgreSQL is slow when counting records without an index. This is a
        workaround which only gives approximate results. see:
        http://wiki.postgresql.org/wiki/Slow_Counting
Fast approximate count of all model instances
Fast approximate count of all model instances
def count_fast(self):
        """Fast approximate count of all model instances

        PostgreSQL is slow when counting records without an index. This is a
        workaround which only gives approximate results. see:
        http://wiki.postgresql.org/wiki/Slow_Counting"""
        cursor = connection.cursor()
        cursor.execute(
            "select reltuples from pg_class where relname='%s';"
            % self.model._meta.db_table
        )
        row = cursor.fetchone()
        return int(row[0])
def count_fast ( self ) : cursor = connection . cursor ( ) cursor . execute ( "select reltuples from pg_class where relname='%s';" % self . model . _meta . db_table ) row = cursor . fetchone ( ) return int ( row [ 0 ] )