def METHOD_NAME(cls, view):
    if view.chain:
        return view.ndb.task_manager.db_fetchone(
            'SELECT count(*) FROM %s WHERE f_ifindex = %s'
            % (view.table, view.ndb.schema.plch),
            [view.chain['index']],
        )
    else:
        return view.ndb.task_manager.db_fetchone(
            'SELECT count(*) FROM %s' % view.table
        )