0

これらの方法は、Mongo Db Driver for C# を使用したクエリに対して、他の方法よりも最適化されていますか?:

var partsLogs = MvcApplication.MongoLoggingDatabase.GetCollection("PartDetailLog") .FindAll()

           .Where(x => x.UserId == UserId)
           .Select(x => new RecentActivityPartsLogDto { OemCode = x.Request.OemCode, OemPartCode = x.Request.OemPartCode, OemPartDescription = x.Request.OemPartDescription, TimeStamp = x.TimeStamp, UserId = x.UserId.ToString() })
           .OrderByDescending(x => x.TimeStamp)
           .Skip(pageSize * (page - 1))
           .Take(pageSize);

または

var doc = new QueryDocument(); doc["UserId"] = UserId;

var partsLogs = MvcApplication.MongoLoggingDatabase.GetCollection("PartDetailLog")

 .Find(doc)              
           .Select(x => new RecentActivityPartsLogDto { OemCode = x.Request.OemCode, OemPartCode = x.Request.OemPartCode, OemPartDescription = x.Request.OemPartDescription, TimeStamp = x.TimeStamp, UserId = x.UserId.ToString()})
           .OrderByDescending(x => x.TimeStamp)
           .Skip(pageSize*(page - 1))
           .Take(pageSize);

このクエリを改善するための他の推奨事項はありますか?

4

1 に答える 1

0

1 つ目はすべてのドキュメントをプルバックしてクライアント側でフィルタリングし、2 つ目はドキュメント サーバー側をフィルタリングして一致するものだけをプルバックします。2枚目を使用。

于 2012-05-22T06:07:49.113 に答える