Skip to content

Inefficient Sitecore path #2

@WizX20

Description

@WizX20

For example: Sitecore.Modules.DMSPoll.Domain.PollEventHandler. The function on line 46: CountPollItemNameDuplicates(string pollName).

This function contains a static path to /sitecore/content in order to find existing polls. When you have a large database, with say, 50.000+ items; the query will take forever. To speed this up I've created an extra setting in my appsettings in the web.config:

Then I changed the code that it would only look at the sub-path when filled, this speeds up the wizard with large databases immensely:

public int CountPollItemNameDuplicates(string pollName) {
using (new SecurityDisabler()) {
if (PollConstants.DatabaseContext != null) {
// Fix: specific path to speed up poll wizzard
string path = "/sitecore/content";
string configPath = System.Web.Configuration.WebConfigurationManager.AppSettings["Sitecore.DMSPoll.Path"];
if (!String.IsNullOrEmpty(configPath)) {
path = configPath;
}

        Item item = PollConstants.DatabaseContext.GetItem(configPath);
        if (item != null) {
            string str = string.Format("@@templateid='{0}' and @@name='{1}'", PollConstants.PollTemplateID, pollName);
            Item[] itemArray = item.Axes.SelectItems(string.Format(".//*[{0}]", str));
            if (itemArray != null)
            {
                return itemArray.Length;
            }
        }
    }
}
return 0;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions