'Returns the number of tables in this query with a non-zero reference
count. Note that after execution, the reference counts are zeroed, so
tables added in compiler will not be seen by this method.'

def count_active_tables(self):

    return len([1 for count in self.alias_refcount.values() if count])
