Skip to content

Commit

Permalink
Update Index for performance
Browse files Browse the repository at this point in the history
Update migration in place. Remove unneeded items from index
  • Loading branch information
Bharts8 authored and Aida committed Apr 17, 2019
1 parent 2409796 commit 4e0ac08
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@ protected override void Up(MigrationBuilder migrationBuilder)

if (migrationBuilder.ActiveProvider == SqlServer)
{
migrationBuilder.Sql(@"UPDATE [dbo].[Machines] SET [NaturalStateName] = CAST(LEFT(JSON_VALUE([StateJson],'$.AssemblyQualifiedName'), CHARINDEX(',', JSON_VALUE([StateJson],'$.AssemblyQualifiedName')) - 1) AS VARCHAR(450))");

migrationBuilder.Sql(@"CREATE NONCLUSTERED INDEX IX_Machines_SchematicName_NaturalStateName_UpdatedTime
ON [dbo].[Machines] ([SchematicName], [UpdatedTime], [NaturalStateName])
INCLUDE ([MachineId], [CommitNumber], [StateJson], [SchematicBytes])");
ON [dbo].[Machines] ([SchematicName] ASC, [UpdatedTime] ASC, [NaturalStateName] ASC)
INCLUDE ([MachineId])");
}
else
{
migrationBuilder.CreateIndex(
name: "IX_Machines_SchematicName_NaturalStateName_UpdatedTime",
table: "Machines",
columns: new[] { "SchematicName", "NaturalStateName", "UpdatedTime" });
columns: new[] { "SchematicName", "NaturalStateName", "UpdatedTime", "MachineId" });
}
}

Expand Down

0 comments on commit 4e0ac08

Please sign in to comment.