dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer
https://dbatools.io
MIT License
2.48k stars 804 forks source link

New function: Invoke-DbaDbIndexRebuild #3862

Open alevyinroc opened 6 years ago

alevyinroc commented 6 years ago

Summary of new feature

Create a new function Invoke-DbaDbIndexRebuild which can rebuild one or more indexes on a collection of tables. Should allow for passing collections of tables, databases, index names and require -AllDatabases if no databases are passed. Should also allow for various index rebuild options like online rebuilds, etc.

Allow for reorgs as well.

This may eventually be called from Invoke-DbaDatabaseUpgrade (optionally) as index rebuilds are needed for some upgrades.

Proposed technical details (if applicable)

Brute force method:

get-dbadatabase -serverinstance YOURSERVER | foreach-object {$PSItem.Tables.Indexes|ForEach-Object {$PSItem.OnlineIndexOperation = $true; $PSItem.Rebuild()};}

Latest version of dbatools as of writing

0.9.382

awickham10 commented 6 years ago

@jpomfret and I were talking about this a few weeks ago - would be cool to see Ola's maintenance recreated as a PowerShell command instead of stored proc!

niphlod commented 6 years ago

on my roster, https://github.com/sqlcollaborative/dbatools/issues/1913

Il giorno gio 4 ott 2018 alle ore 15:55 Andrew Wickham < notifications@github.com> ha scritto:

@jpomfret https://github.com/jpomfret and I were talking about this a few weeks ago - would be cool to see Ola's maintenance recreated as a PowerShell command instead of stored proc!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sqlcollaborative/dbatools/issues/3862#issuecomment-427028160, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHdB5cuV0c_M2HpBQAFwHQ6F7JSv0ZTks5uhhNJgaJpZM4VohGs .

awickham10 commented 6 years ago

I was thinking a full recreation, not just invoking Ola's scripts. Tons of work, probably not much benefit other than not having to have Ola's maintenance installed everywhere.

niphlod commented 6 years ago

at the very worst you can install, run, uninstall. But I really don't see the benefit of reinventing the wheel given there are no shortcomings on both ola's and tiger's tsql routines....

dlh275 commented 6 years ago

If I could suggest, please allow for rebuild of heaps as well as Ola's scripts do not support heaps.

github-actions[bot] commented 3 years ago

🚧🚨 This issue is being marked as stale due to 90 days of inactivity. If you would like this issue to remain open: