Tips and tricks for improving search speed across your Sitecore XM/XP SXA site

At Macmillan Cancer Support, we have been working on a number of changes to improve site speed, both in terms of optimising data retrieval from Solr indexes and improving Core Web Vitals across our site. In this article, I’ll focus on search.
Background
We are currently running a Sitecore XP scaled topology with a multi-site environment. We use SXA and rely on SXA search endpoints for the various bits of search functionality across our website.
Improving retrieval of data from indexes and index rebuild times
-
We were seeing slow retrieval of indexed data through our SXA search endpoints. The single most impactful change we made to improve the speed of retrieval was to change the ‘defaultSearchSecurityOption’ and ‘enableReadAccessIndexing’ settings within the site-specific index configurations. We have now set them to the following values:
<defaultSearchSecurityOption>DisableSecurityCheck</defaultSearchSecurityOption> <enableReadAccessIndexing>false</enableReadAccessIndexing>For public-facing search, we did not need to have the ‘defaultSearchSecurityOption’ set to ‘EnableSecurityCheck’ because we are not returning different search results to users with different permissions.
We did not need the ‘enableReadAccessIndexing’ setting to be set to ‘true’ because we don’t need to store permissions within the index. Setting it to ‘false’ slims down the size of the Solr indexes. You can find more details on security options for your indexes here: Use permissions for search | Sitecore Documentation.
-
Another change we made recently was to change the default Solr index configurations from an exclude list to an include list. In other words, we now only index the template fields that we use to serve data back to end users. While we had an exclude, all content from across the site added to template fields that were not in the exclude list would be indexed. This caused indexes to swell over time as new templates were created, and the list of fields to exclude was not maintained. Changing the index configuration to an include list (to include only the fields needing to be indexed) resulted in a significant improvement in search performance on our website, and had an even greater impact on the amount of time it takes to rebuild indexes from Sitecore CM. A full index rebuild of all of our content now runs 6 times faster than it used to.
Use something like:
<documentOptions> <indexAllFields>false</indexAllFields> <include hint="list:AddIncludedField"> PUT YOUR FIELDS TO INCLUDE HERE </include> </documentOptions> -
For a Sitecore XP multi-site setup, Sitecore recommend splitting indexes per site to optimise performance. Whilst we saw only a small improvement from making this change in terms of the amount of time it takes to return data from our Solr indexes, the change was still valuable for the following reasons:
- Having small index sizes means there are smaller index rebuilds. If search results are not appearing in the cancer A-Z, across Fundraising event pages, Mighty Hikes pages or Coffee Morning events, we now only need to rebuild much smaller indexes. This is much quicker than having to wait for a full index rebuild to complete. We get:
- Faster rebuild times
- Less Solr CPU usage during rebuilds
- Reduced risk when rebuilding the indexes for an individual site (which sometimes also could mean reduced deployment times, depending on what is in the release)
- We have moved towards Sitecore’s recommended indexing architecture in line with their recommendation to create separate master and web indexes per SXA site to reduce size and increase performance of indexes while only crawling the relevant parts of the content tree. See: Configure SXA indexing | Sitecore Documentation for more details.
- Having small index sizes means there are smaller index rebuilds. If search results are not appearing in the cancer A-Z, across Fundraising event pages, Mighty Hikes pages or Coffee Morning events, we now only need to rebuild much smaller indexes. This is much quicker than having to wait for a full index rebuild to complete. We get:
