.Net Any faster way of writing docs to disk other than CreateDocument() & PutProperties()?

I’m running a couple of performance benchmarks for CBL .NET and when trying to generate a lot of documents (1M+) it looks like I can only create documents at a rate of about 1,000 docs every 30 sec or so. While this isn’t bad for most of my usages, I am curious if there is a better way of doing so.

I’m using the following code:

while (db.GetDocumentCount() < 1000000)
{
    Log.I(Tag, $"Document count: {db.GetDocumentCount()}");
    for (int i = 0; i < 1000; i++)
    {
        var doc = db.CreateDocument();
        doc.PutProperties(
            new Dictionary<string, object>
            {
                { "SentTimeStamp", DateTime.Now.ToString("G") }
            }
        });
    }
}
Log.I(Tag, $"Document count: {db.GetDocumentCount()}");

It will be much faster to do all of this inside of a RunInTransaction block.

1 Like

Great! That made a noticeable difference. I don’t think I was able to find any documentation on that other than the brief summary in the API reference. How does that work? Is it batching it under the covers? If so do you know what the ideal “batch” would be? Or is it faster because it merges the create and update operation?