Search code examples
c#xpathxpathnavigator

XPathNavigator performance with large secondary datasource


I have a secondary DataSource with about 23k entries. The User inputs an ID and gets only 1 Dataset back. If I use:

XPathNavigator test = nav.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[d:Title = '" + ID + "']", NamespaceManager);

it takes about 8 seconds to return the Node. Is there a better (faster) way?


Solution

  • You can collect all the SharePointListItem_RW nodes in a Dictionary (key would be the title id and the value would be the node that contains the title as id) at the start of your app..

    [Memory consumption would not be an issue here since it would hardly cross 1MB]

    Then you can select the particular node by using TryGetValue method of Dictionary

    The complexity would be O(1) which is fast