【发布时间】:2015-01-12 05:28:27
【问题描述】:
我正在尝试新的 ArangoDb-Net 重新实现驱动程序 https://github.com/yojimbo87/ArangoDB-NET/tree/reimplement。今天是我第一次尝试表演。当我使用 araongosh 执行插入时。它每秒可以插入大约 5000 条记录。但是,当我使用 .Net 驱动程序执行相同的更新时。我花了大约 2 分钟来执行相同的插入。我可以知道我做错了什么吗?谢谢。
[编辑] 完成问题with the github discussion 我已经用我的 arangosh 测试了下面的代码
count=1;
startTime=+new Date();
console.log(startTime);
while(count <= 10000)
{
db.someCollection.save({"Id":"1234567890123456789012345678901234",
"Key":1234567,
"Revision":1234567,
"Name":"Mohamad Abu Bakar",
"IC Number":"1234567-12-3444",
"Department":"IT Department",
"Height":1234,
"DateOfBirth":"2015-01-27 03:33",
"Salary":3333});
count++;
}
endTime=+new Date();
console.log(endTime);
console.log("Total time taken:" + (endTime - startTime)/1000);
完成操作耗时 3.375 秒。
我用 .Net 驱动程序做了类似的事情,它花了将近 9.5797819。几乎是阿兰戈什的三倍。这是.Net中的代码:
public static void TestArangoDb()
{
//ASettings.AddConnection("_system", "127.0.0.1", 8529, false, "_system");
//var db = new ADatabase("_system");
//db.Create("trial_sample");
ASettings.AddConnection("trial_sample",
"127.0.0.1", 8529, false, "trial_sample");
var db2 = new ADatabase("trial_sample");
db2.Collection.Create("someCollection");
DateTime startTime = DateTime.Now;
Console.WriteLine("Start Time: " + startTime.ToLongTimeString());
for(int count=1; count <= 10000; count++)
{
var employee = new Employee();
employee.Id = "1234567890123456789012345678901234";
employee.Key = "1234567";
employee.Revision = "1234567";
employee.Name = "Mohamad Abu Bakar";
employee.IcNumber = "1234567-12-3444";
employee.Department = "IT Department";
employee.Height = 1234;
employee.DateOfBirth = new DateTime(2015, 1, 27, 3, 33, 3);
employee.Salary = 3333;
var result = db2.Document.Create<Employee>("someCollection", employee);
//var updateDocument = new Dictionary<string, object>()
// .String("DocumentId", "SomeId");
//db2.Document.Update(result.Value.String("_id"), updateDocument);
}
DateTime endTime = DateTime.Now;
TimeSpan duration = endTime - startTime;
Console.WriteLine("End Time: " + endTime.ToLongTimeString());
Console.WriteLine("Total time taken: " + duration.TotalSeconds);
}
public class Employee
{
public string Id { get; set; }
public string Key { get; set; }
public string Revision { get; set; }
public string Name { get; set; }
public string IcNumber { get; set; }
public string Email { get; set; }
public string Department { get; set; }
public double Height { get; set; }
public DateTime DateOfBirth { get; set; }
public decimal Salary { get; set; }
}
如果我删除以下评论:
var updateDocument = new Dictionary<string, object>()
.String("DocumentId", "SomeId");
db2.Document.Update(result.Value.String("_id"), updateDocument);
性能几乎是 30 倍。完成耗时 99.8789133 秒。事实上,我只是执行额外的更新来添加额外的列。
您能就上面代码中的问题提出建议吗?谢谢。
【问题讨论】:
-
您能提供您通过驱动程序插入的数据的示例吗? 2 分钟内完成了多少次插入?这可能是一个较长的讨论,所以我建议在 ArangoDB 谷歌群组上讨论它,一旦问题解决,答案将在这里发布。
-
当然。我将在 google 群组中发布我的问题。
-
您能否发布指向 google 小组主题的链接,以便我们在本网站上查看除了最终答案之外的讨论吗?
-
这仍然是一个问题吗?我在 google 群组中找不到主题
-
这可能是arangosh为此做了多少请求的问题;也许 Wireshark 可以告诉你更多信息?由于最近没有反馈,这仍然是一个问题吗?
标签: arangodb