SET ANSI_NULLS ON; SET QUOTED_IDENTIFIER ON; GO IF NOT EXISTS(SELECT 1 FROM sys.indexes WHERE object_id=OBJECT_ID('dbo.LocationGeography') AND name='IX_LocationGeography_Queue') CREATE INDEX IX_LocationGeography_Queue ON dbo.LocationGeography(JobState,NextAttempt) INCLUDE(LeaseUntil); IF NOT EXISTS(SELECT 1 FROM sys.indexes WHERE object_id=OBJECT_ID('dbo.GeographicAuthorBatch') AND name='IX_GeographicAuthorBatch_Time') CREATE INDEX IX_GeographicAuthorBatch_Time ON dbo.GeographicAuthorBatch(RequestedAt) INCLUDE(UserID); GO