Executing queries against the Links table might result in increased CPU/DTU consumption. In this case, operations that require access to the Link Database tend to get slower. The article provides recommendations on reducing the query execution time for the Link Database by creating the SQL indexes on the Links table.
To reduce the query execution time for the Link Database:
ALTER TABLE [Links] ALTER COLUMN TargetPath NVARCHAR(MAX) NOT NULL
CREATE NONCLUSTERED INDEX [ndxSourceItemIdSourceDatabase] ON [dbo].[Links] ( [SourceItemID] ASC, [SourceDatabase] ASC ) INCLUDE ([TargetDatabase],[TargetItemId],[SourceLanguage],[SourceVersion],[SourceFieldID],[TargetLanguage],[TargetVersion],[TargetPath]) 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
CREATE NONCLUSTERED INDEX [ndxTargetItemIdTargetDatabase] ON [dbo].[Links] ( [TargetItemId] ASC, [TargetDatabase] ASC ) INCLUDE ([SourceDatabase],[SourceItemID],[SourceLanguage],[SourceVersion],[SourceFieldID],[TargetLanguage],[TargetVersion],[TargetPath]) 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
Note: The previous steps help to reduce query execution time in most environments. However, we recommend that the changes are tested in a pre-production environment before rolling out to production. It is necessary to ensure that the cost of maintaining the indexes (updating the indexes when data changes) does not outweigh the boost in query performance.