Skip to content

Commit 4bdebe4

Browse files
sp_IndexCleanup: fix heap table index detection (#727)
The partition stats row count filter used ps.index_id = 1 which only matches clustered indexes. Heaps use index_id = 0, so heap tables were excluded entirely from deduplication analysis. Changed to ps.index_id IN (0, 1) to include both heaps and clustered. Closes #727 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b30766c commit 4bdebe4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

sp_IndexCleanup/sp_IndexCleanup.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2311,7 +2311,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23112311
nvarchar(MAX),
23122312
N'.sys.dm_db_partition_stats ps
23132313
WHERE ps.object_id = i.object_id
2314-
AND ps.index_id = 1
2314+
AND ps.index_id IN (0, 1)
23152315
AND ps.row_count >= @min_rows
23162316
)'
23172317
);

0 commit comments

Comments
 (0)