Skip to content

Commit ff31fa4

Browse files
committed
Perf: Include IsSystemProduct in published-deleted compound index. It speeds up linq search.
1 parent d61ae3c commit ff31fa4

5 files changed

Lines changed: 191 additions & 4 deletions

File tree

src/Libraries/SmartStore.Core/Domain/Catalog/Product.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,26 +710,29 @@ public decimal Height
710710
/// Gets or sets a value indicating whether the entity is published
711711
/// </summary>
712712
[DataMember]
713-
public bool Published { get; set; }
713+
[Index("IX_Product_Published_Deleted_IsSystemProduct", 1)]
714+
public bool Published { get; set; }
714715

715716
/// <summary>
716717
/// Gets or sets a value indicating whether the entity has been deleted
717718
/// </summary>
718719
[Index]
720+
[Index("IX_Product_Published_Deleted_IsSystemProduct", 2)]
719721
public bool Deleted { get; set; }
720722

721723
/// <summary>
722724
/// Gets or sets a value indicating whether the entity is a system product.
723725
/// </summary>
724726
[DataMember]
725-
[Index("Product_SystemName_IsSystemProduct", 2)]
726-
public bool IsSystemProduct { get; set; }
727+
[Index("IX_Product_SystemName_IsSystemProduct", 2)]
728+
[Index("IX_Product_Published_Deleted_IsSystemProduct", 3)]
729+
public bool IsSystemProduct { get; set; }
727730

728731
/// <summary>
729732
/// Gets or sets the product system name.
730733
/// </summary>
731734
[DataMember]
732-
[Index("Product_SystemName_IsSystemProduct", 1)]
735+
[Index("IX_Product_SystemName_IsSystemProduct", 1)]
733736
public string SystemName { get; set; }
734737

735738
/// <summary>

src/Libraries/SmartStore.Data/Migrations/201811061745204_IsSystemProductIndex.Designer.cs

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace SmartStore.Data.Migrations
2+
{
3+
using System;
4+
using System.Data.Entity.Migrations;
5+
6+
public partial class IsSystemProductIndex : DbMigration
7+
{
8+
public override void Up()
9+
{
10+
DropIndex("dbo.Product", "IX_Product_Deleted_and_Published");
11+
RenameIndex(table: "dbo.Product", name: "Product_SystemName_IsSystemProduct", newName: "IX_Product_SystemName_IsSystemProduct");
12+
CreateIndex("dbo.Product", new[] { "Published", "Deleted", "IsSystemProduct" }, name: "IX_Product_Published_Deleted_IsSystemProduct");
13+
}
14+
15+
public override void Down()
16+
{
17+
DropIndex("dbo.Product", "IX_Product_Published_Deleted_IsSystemProduct");
18+
RenameIndex(table: "dbo.Product", name: "IX_Product_SystemName_IsSystemProduct", newName: "Product_SystemName_IsSystemProduct");
19+
CreateIndex("dbo.Product", new[] { "Published", "Deleted" }, name: "IX_Product_Deleted_and_Published");
20+
}
21+
}
22+
}

src/Libraries/SmartStore.Data/Migrations/201811061745204_IsSystemProductIndex.resx

Lines changed: 126 additions & 0 deletions
Large diffs are not rendered by default.

src/Libraries/SmartStore.Data/SmartStore.Data.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,10 @@
636636
<Compile Include="Migrations\201810231214068_DataExchangeEnhancements.Designer.cs">
637637
<DependentUpon>201810231214068_DataExchangeEnhancements.cs</DependentUpon>
638638
</Compile>
639+
<Compile Include="Migrations\201811061745204_IsSystemProductIndex.cs" />
640+
<Compile Include="Migrations\201811061745204_IsSystemProductIndex.Designer.cs">
641+
<DependentUpon>201811061745204_IsSystemProductIndex.cs</DependentUpon>
642+
</Compile>
639643
<Compile Include="ObjectContextBase.SaveChanges.cs" />
640644
<Compile Include="Setup\Builder\ActivityLogTypeMigrator.cs" />
641645
<Compile Include="Setup\Builder\PermissionMigrator.cs" />
@@ -1142,6 +1146,9 @@
11421146
<EmbeddedResource Include="Migrations\201810231214068_DataExchangeEnhancements.resx">
11431147
<DependentUpon>201810231214068_DataExchangeEnhancements.cs</DependentUpon>
11441148
</EmbeddedResource>
1149+
<EmbeddedResource Include="Migrations\201811061745204_IsSystemProductIndex.resx">
1150+
<DependentUpon>201811061745204_IsSystemProductIndex.cs</DependentUpon>
1151+
</EmbeddedResource>
11451152
<EmbeddedResource Include="Sql\Indexes.sql" />
11461153
<EmbeddedResource Include="Sql\StoredProcedures.sql" />
11471154
</ItemGroup>

0 commit comments

Comments
 (0)