Browse files

Added NONCLUSTERED INDEX on EventSourceId in table [dbo].[Events] in …


When running the following query without index:
SELECT [Id], [EventSourceId], [Name], [Version], [TimeStamp], [Data], [Sequence] FROM [Events] WHERE [EventSourceId] = @EventSourceId AND [Sequence] >= @EventSourceMinVersion AND [Sequence] <= @EventSourceMaxVersion ORDER BY [Sequence]
On an eventstore with 1074011 records the result takes 28235 milliseconds.
With index created it takes: 62 milliseconds
  • Loading branch information...
1 parent c1dd378 commit eee81fa904c8c382d9f48247c485763b58d2012e @jansaris jansaris committed May 15, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 Framework/src/Ncqrs/Eventing/Storage/SQL/TableCreationScript.sql
@@ -21,6 +21,8 @@ CREATE TABLE [dbo].[Events](
+CREATE NONCLUSTERED INDEX IX_EventSourceId ON [dbo].[Events] (EventSourceId)
CREATE TABLE [dbo].[EventSources]
[Id] [uniqueidentifier] NOT NULL, [Type] [nvarchar](255) NOT NULL, [Version] [int] NOT NULL

0 comments on commit eee81fa

Please sign in to comment.