Skip to content

Commit b984113

Browse files
Update sp_IndexCleanup.sql
1 parent 6685753 commit b984113

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

sp_IndexCleanup/sp_IndexCleanup.sql

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
476476
last_user_lookup datetime NULL,
477477
last_user_update datetime NULL,
478478
is_eligible_for_dedupe bit NOT NULL
479-
PRIMARY KEY CLUSTERED(database_id, object_id, index_id, column_name)
479+
PRIMARY KEY CLUSTERED(database_id, schema_id, object_id, index_id, column_id)
480480
);
481481

482482
CREATE TABLE
@@ -512,7 +512,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
512512
superseded_by nvarchar(4000) NULL,
513513
/* Priority score from 0-1 to determine which index to keep (higher is better) */
514514
index_priority decimal(10,6) NULL
515-
PRIMARY KEY CLUSTERED(database_id, object_id, index_id)
515+
PRIMARY KEY CLUSTERED(database_id, schema_id, object_id, index_id)
516516
);
517517

518518
CREATE TABLE
@@ -528,7 +528,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
528528
index_name sysname NOT NULL,
529529
can_compress bit NOT NULL,
530530
reason nvarchar(200) NULL,
531-
PRIMARY KEY CLUSTERED(database_id, object_id, index_id)
531+
PRIMARY KEY CLUSTERED(database_id, schema_id, object_id, index_id)
532532
);
533533

534534
CREATE TABLE
@@ -564,7 +564,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
564564
base_key_columns nvarchar(max) NULL,
565565
filter_definition nvarchar(max) NULL,
566566
winning_index_name sysname NULL,
567-
index_list nvarchar(max) NULL,
567+
index_list nvarchar(max) NULL
568568
);
569569

570570
CREATE TABLE
@@ -924,13 +924,20 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
924924
RAISERROR('Truncating per-database temp tables for the next iteration', 0, 0) WITH NOWAIT;
925925
END;
926926

927-
TRUNCATE TABLE #filtered_objects;
928-
TRUNCATE TABLE #operational_stats;
929-
TRUNCATE TABLE #partition_stats;
930-
TRUNCATE TABLE #index_details;
931-
TRUNCATE TABLE #compression_eligibility;
932-
TRUNCATE TABLE #key_duplicate_dedupe;
933-
TRUNCATE TABLE #include_subset_dedupe;
927+
TRUNCATE TABLE
928+
#filtered_objects;
929+
TRUNCATE TABLE
930+
#operational_stats;
931+
TRUNCATE TABLE
932+
#partition_stats;
933+
TRUNCATE TABLE
934+
#index_details;
935+
TRUNCATE TABLE
936+
#compression_eligibility;
937+
TRUNCATE TABLE
938+
#key_duplicate_dedupe;
939+
TRUNCATE TABLE
940+
#include_subset_dedupe;
934941

935942
/*Validate searched objects per-database*/
936943
IF @schema_name IS NOT NULL

0 commit comments

Comments
 (0)