Reputation: 13377
Simple question: How to export data from SQL Server to RavenDB?
I wrote script which takes data from SQL Server and stores in raven but it works very slow. About 2500 inserts per second.
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();
}
}
Upvotes: 1
Views: 1719
Reputation: 36
I believe its supported for 1,000 writes per second on standard server.
When I increased my cache size the performance increased. Raven/Esent/CacheSizeMax
http://ravendb.net/docs/server/administration/configuration
Upvotes: 0
Reputation: 19153
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();
}
}
Upvotes: 1