Permalink
Browse files

Adding indexes to packages tables

  • Loading branch information...
1 parent 4be827f commit e8a6ef468ead6e453c58cba2cc38bbc135717be5 @pranavkm pranavkm committed Aug 22, 2012

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,33 @@
+namespace NuGetGallery.Migrations
+{
+ using System.Data.Entity.Migrations;
+
+ public partial class PackageIndexes : DbMigration
+ {
+ public override void Up()
+ {
+ // Used by VS search.
+ Sql(@"Create NonClustered Index IX_Package_Search On [dbo].[Packages] ([IsLatestStable],[IsLatest],[Listed],[IsPrerelease])
+ Include ([Key],[PackageRegistrationKey],[Description],[Summary],[Tags])");
+
+ // Used in the package page
+ Sql(@"Create NonClustered Index IX_PackageDependencies On [dbo].[PackageDependencies] ([PackageKey])
+ Include ([Key])");
+
+ // Used for paging and sorting results
+ CreateIndex(table: "Packages", columns: new[] { "PackageRegistrationKey", "Version" }, unique: true, name: "IX_Package_Version");
+
+ // Adding an index on the package Id in PackageRegistrations
+ Sql(@"Create Unique Index IX_PackageRegistration_Id on [dbo].[PackageRegistrations] (DownloadCount desc, Id asc)
+ Include ([Key])");
+ }
+
+ public override void Down()
+ {
+ DropIndex(table: "Packages", name: "IX_Package_Search");
+ DropIndex(table: "PackageDependencies", name: "IX_PackageDependencies");
+ DropIndex(table: "Packages", name: "IX_Package_Version");
+ DropIndex(table: "PackageRegistrations", name: "IX_PackageRegistration_Id");
+ }
+ }
+}
View
@@ -362,6 +362,10 @@
<Compile Include="Migrations\201208222206329_ColumnLengthOfPackageTable.Designer.cs">
<DependentUpon>201208222206329_ColumnLengthOfPackageTable.cs</DependentUpon>
</Compile>
+ <Compile Include="Migrations\201208222227425_PackageIndexes.cs" />
+ <Compile Include="Migrations\201208222227425_PackageIndexes.Designer.cs">
+ <DependentUpon>201208222227425_PackageIndexes.cs</DependentUpon>
+ </Compile>
<Compile Include="Migrations\MigrationsConfiguration.cs" />
<Compile Include="PackageCurators\IAutomaticPackageCurator.cs" />
<Compile Include="PackageCurators\AutomaticPackageCurator.cs" />

0 comments on commit e8a6ef4

Please sign in to comment.