Wednesday, May 9, 2018

Sitecore Buckets and Improving bulk import speed


I ran into a problem while trying to bulk insert items into a bucket in code, using the Glass Mapper SitecoreService - insert speed was very slow (10,000 items took 50 minutes). Deleting all items from the bucket was also fairly slow.

The solution in code is basically the same as the Powershell equivalent in the link above: -

            using (new Sitecore.Data.BulkUpdateContext())
            using (new SecurityDisabler()) // yes yes I know

                foreach (var item in data)
                    sitecoreService.Create(folderItem, item, false, true);

Yes I know I should be using a UserSwitcher instead of disabling all security..

Total import time down from 90 minutes to 6. Not bad :)

No comments:

Post a Comment