Suddenly my index updates took forever to finish. I mean, one index update would take 2 minutes. And I have a lot of index updates. A lot.

After some panic and some SQL debugging we were lead to some long running SQL statements that looked like this:
SELECT *
FROM [Sitecore_Web].[dbo].[Links]
where TargetItemID = '562F77DD-6C00-4BE1-AF0E-9F9EEAA8CCEF'
and TargetDatabase = 'master'
One of these would take almost 2 minutes to finish.
Now, my master database contains 2.000.000+ items, increasing with at least 5.000 items per week. Each of my items points to a category item, and each category item can have 250.000+ links to them. So there is a lot of rows in the Links database. 36.000.000 to be exact.
Inside the Links database there is several indexes, but none of them on TargetItemID and TargetDatabase. So we tried to create the index ourselves:
CREATE NONCLUSTERED INDEX [IX_TargetDatabaseTargetItemID] ON [dbo].[Links]
(
[TargetDatabase] ASC,
[TargetItemID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
And voila! After a system restart, my index updates was back on track.
FINAL NOTES:
First of all, I usually don’t create indexes on databases that I do not own. And I cannot guarantee that the index solved all of my problems. It just so happens that after the index was introduced, my system is running fine.
MORE TO READ:
- Sitecore high memory usage – not always a problem by briancaos
- Sitecore Memory Issues – Every memory optimization trick in the book by briancaos
- What Is Wrong With the Link Database from Ian’s Blog
- Improved Sitecore Links Database provider by Mikael Högberg
- How To Rebuild Your Sitecore Link Database from JohnDJones
- Rebuild Link Database taking way long from Sitecore Competencies