New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IndexOptimize: Heap (de)fragmentation #48
Comments
This would be a very welcome addition |
This makes complete sense. There are some situations in which is needed to rebuild a heap (a new datafile was added, for example). If we could have a @RebuildHEAP option in the solution, it would be great ! |
+1. I'm managing a vendor DB with 1400+ heap tables. An option to rebuild heaps would be quite welcome. :) |
Guys, as we wait for this new feature, I share the code I use in a job to accomplish this task. As it is, it only creates and shows the syntax needed. Uncomment the EXEC line to put it to work. I think you already have written something like this, but this can be helpful to someone. --> BEGIN SCRIPTDECLARE @Tablename SYSNAME; DECLARE Cursor_Heaps CURSOR LOCAL STATIC READ_ONLY FORWARD_ONLY FOR SELECT SCH.name + '.' + TBL.name OPEN Cursor_Heaps; FETCH NEXT FROM Cursor_Heaps INTO @Tablename; WHILE @@fetch_status = 0 END; CLOSE Cursor_Heaps; DEALLOCATE Cursor_Heaps;--> END SCRIPT |
Thanks, @EmilioBoucau . I have also been working on a sproc to help rebuild heaps. It only rebuilds ones that have user scans in the last x # of days and non-zero forward fetch counts. My first public repo: |
+1 on this request |
Brent Ozar has a valid suggestion here for an intermediary fix: https://www.brentozar.com/archive/2016/07/fix-forwarded-records/#:~:text=Ola%20Hallengren%E2%80%99s%20IndexOptimize%20does%20not%20rebuild%20heaps |
See https://www.brentozar.com/archive/2016/07/fix-forwarded-records/ on advice to modify IndexOptimize for this situation. I work with a lot of vendor applications. Getting vendor approval for clustered indexes meets a ton of resistance even after doing writeups with facts. Rebuilding heaps using an existing solution is the way to go. |
Feature request - adding the ability to identify and "fix" heap fragmentation.
I know a heap is usually a bad idea and that heap maintenance is a pain, but there are some valid use cases for heaps.
The text was updated successfully, but these errors were encountered: