Skip to content

Say that an index rebuild can clear missing index requests - #10465

Open
Rudi Bruchez (rudi-bruchez) wants to merge 1 commit into
MicrosoftDocs:livefrom
rudi-bruchez:fix/missing-index-alter-index-rebuild
Open

Rudi Bruchez (rudi-bruchez) wants to merge 1 commit into
MicrosoftDocs:livefrom
rudi-bruchez:fix/missing-index-alter-index-rebuild

Conversation

@rudi-bruchez

Copy link
Copy Markdown
Contributor

What's wrong

In tune-nonclustered-missing-index-suggestions.md, section "Missing index suggestions are cleared", the page says: "Performing an ALTER INDEX operation on an index on a table also clears missing index requests for that table." In the test below, a rebuild cleared the suggestion. ALTER INDEX ... REORGANIZE, SET (...) and DISABLE left the tested suggestion in place, even when the reorganization removed almost all the fragmentation of the index.

Evidence

SQL Server 2025 CU7 (17.0.4065.4) and CU10 (17.0.5035.5), SQL Server 2022 CU27-GDR (16.0.4305.5), Developer, Linux containers. Fresh database.

CREATE TABLE dbo.T (id int NOT NULL PRIMARY KEY, k uniqueidentifier NOT NULL DEFAULT NEWID(),
                    v int NOT NULL, pad char(200) NOT NULL DEFAULT '');
CREATE INDEX IX_T_k ON dbo.T (k);
INSERT dbo.T (id, v) SELECT value, value % 1000 FROM GENERATE_SERIES(1, 200000);
UPDATE dbo.T SET k = NEWID();  -- new random keys: page splits in IX_T_k
GO
CREATE VIEW dbo.Check_ AS
SELECT (SELECT COUNT(*) FROM sys.dm_db_missing_index_details
        WHERE object_id = OBJECT_ID(N'dbo.T')) AS suggestions,
       (SELECT CAST(avg_fragmentation_in_percent AS decimal(5,1))
        FROM sys.dm_db_index_physical_stats(DB_ID(), OBJECT_ID(N'dbo.T'), 2, NULL, 'LIMITED')) AS ix_fragmentation_pct;
GO
SELECT COUNT(*) AS n FROM dbo.T WHERE v = 42;  -- asks for an index on v
GO
SELECT 'before' AS step, * FROM dbo.Check_;
ALTER INDEX IX_T_k ON dbo.T REORGANIZE;
SELECT 'after REORGANIZE' AS step, * FROM dbo.Check_;
ALTER INDEX IX_T_k ON dbo.T REBUILD;
SELECT 'after REBUILD' AS step, * FROM dbo.Check_;

Observed (2025 CU7; the other builds give the same suggestion counts):

step              suggestions  ix_fragmentation_pct
before            1            65.6
after REORGANIZE  1            0.6
after REBUILD     0            3.2

On 2025 CU7, with the suggestion generated again before each step: ALTER INDEX ... SET (ALLOW_PAGE_LOCKS = OFF), ALTER INDEX ... DISABLE, ALTER INDEX on the clustered primary key with REORGANIZE and ALTER INDEX ALL ... REORGANIZE keep the suggestion; ALTER INDEX ... REBUILD WITH (ONLINE = ON) clears it.

Change

Replaces "Performing an ALTER INDEX operation on an index on a table also clears" with "Rebuilding an index on a table with ALTER INDEX can also clear".

@prmerger-automator

Copy link
Copy Markdown
Contributor

Rudi Bruchez (@rudi-bruchez) : Thanks for your contribution! The author(s) and reviewer(s) have been notified to review your proposed change.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 9deb3a7:

✅ Validation status: passed

File Status Preview URL Details
docs/relational-databases/indexes/tune-nonclustered-missing-index-suggestions.md ✅Succeeded

For more details, please refer to the build report.

@v-dirichards

Copy link
Copy Markdown
Contributor

Derek Wilson (@thesqlsith)

Can you review the proposed changes?

Important: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The documentation change accurately narrows the behavior from all index operations to index rebuilds.

No open issues 🎉

What changed in this PR

Updates the missing-index documentation to clarify that an ALTER INDEX ... REBUILD operation can clear missing-index requests, rather than implying that every ALTER INDEX operation does so.

Changes:

  • Replaces the overly broad statement about all ALTER INDEX operations.
  • Specifies index rebuilds as the operation that can clear requests.
File Description
docs/​relational-databases/​indexes/​tune-nonclustered-missing-index-suggestions.md Clarifies when rebuilding an index can clear missing-index requests.

Review effort: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants