Flag Performance mongo Count ()

Given this shell:

    public MongoCollection<TEntity> GetQuery<TEntity>() where TEntity : class
    {
        var query = DataBase.GetCollection<TEntity>(typeof(TEntity).Name + "s");
        return query;
    }

    public long Count<TEntity>(System.Linq.Expressions.Expression<Func<TEntity, bool>> criteria) where TEntity : class
    {
        return this.GetQuery<TEntity>().AsQueryable().Count(criteria);
    }

If I call Count (), the request will be executed on the server, as indicated in the documentation here ?

var count = db<MyEntity>.Count(x => x.Foo = "foo");
+3
source share
1 answer

Yes. It will be executed on the server side. You can verify this by deploying profiling on the mongodb server and seeing what happens.

+3
source

All Articles