microsoft / microsoft/sqlmanagementobjects
Obtaining Table SMO object causes table scan to be recorded
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 143
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
I'm not sure what the fix is here, but, that CASE statement does not short-circuit. Even if the IF condition is true, it still executes the subquery in the ELSE clause.
This means a table scan on one of the indexes (or heap) is recorded.
In most cases, this is probably not a big deal...but if you're using SMO objects to create backup scripts for unused indexes you are getting ready to drop...it's kind of a problem when all of a sudden SMO starts using those unused indexes, causing them to be excluded from the unused index detection queries.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/Microsoft/SqlServer/Management/SqlEnum/PostProcessTable.cs around lines 81-83 and inspect the query path used when obtaining a Table SMO object. Reproduce or trace the table-scan recording behavior, then verify that unused-index detection no longer treats this metadata lookup as index usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100