async def count(query, clear_limit=False):
clone = query.clone()<EOL>if query._distinct or query._group_by or query._limit or query._offset:<EOL><INDENT>if clear_limit:<EOL><INDENT>clone._limit = clone._offset = None<EOL><DEDENT>sql, params = clone.sql()<EOL>wrapped = '<STR_LIT>' % sql<EOL>raw = query.model.raw(wrapped, *params)<EOL>return (await scalar(raw)) or <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>clone._returning = [peewee.fn.Count(peewee.SQL('<STR_LIT:*>'))]<EOL>clone._order_by = None<EOL>return (await scalar(clone)) or <NUM_LIT:0><EOL><DEDENT>
Perform *COUNT* aggregated query asynchronously.

    :return: number of objects in ``select()`` query