简体   繁体   English

RavenDB导出/导入数据到SQL Server

[英]RavenDB export\import data to SQL Server

Simple question: How to export data from SQL Server to RavenDB? 一个简单的问题:如何将数据从SQL Server导出到RavenDB?

I wrote script which takes data from SQL Server and stores in raven but it works very slow. 我编写了脚本,该脚本从SQL Server获取数据并将其存储在raven中,但是它的运行速度非常慢。 About 2500 inserts per second. 每秒约2500次插入。

EDIT: My code 编辑:我的代码

    for (int i = 0; i < count; i+=8196)
    {
        StoreInTaven(WordStats.Skip(i).Take(8196).Select(x => new KeyPhraseInfo(){
           Key = x.Word,
           Id = x.Id,
           Count = x.Count,
           Date = x.Date
        }));
        GC.Collect();
    }



public static void StoreInTaven(IEnumerable<KeyPhraseInfo> wordStats)
{
     using(var session = store.OpenSession())
     {
           foreach (var wordStat in wordStats)
           {
              session.Store(wordStat);
           }

           session.SaveChanges();
     }
}

I was just doing the same thing. 我只是在做同样的事情。 Speed is not really a concern for me so I don't know if this is any faster than yours. 速度并不是我真正关心的问题,因此我不知道这是否比您快。

public static void CopyFromSqlServerToRaven(IDocumentSession db, bool ravenDeleteAll=true)
{
    if (ravenDeleteAll) db.DeleteAll();

    using (var connection = new SqlConnection(SqlConnectionString))
    {
        var command = new SqlCommand(SqlGetContentItems, connection);
        command.Connection.Open();
        using (var reader = command.ExecuteReader())
        {
            while (reader.Read())
            {
                db.Store(new ContentItem
                            {
                                    Id = reader["Id"].ToString(),
                                    Title = (string)reader["Name"],
                                    Description = (string)reader["ShortDescription"],
                                    Keywords = (string)reader["SearchKeywords"]
                            });
            }
        }
        db.SaveChanges();
    }
}

I believe its supported for 1,000 writes per second on standard server. 我相信它在标准服务器上每秒支持1,000次写入。

When I increased my cache size the performance increased. 当我增加缓存大小时,性能会提高。 Raven/Esent/CacheSizeMax Raven / Esent / CacheSizeMax

http://ravendb.net/docs/server/administration/configuration http://ravendb.net/docs/server/administration/configuration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM