Skip to content
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

How can I remove an index in a good way? #402

Closed
jden123 opened this issue Mar 16, 2020 · 3 comments
Closed

How can I remove an index in a good way? #402

jden123 opened this issue Mar 16, 2020 · 3 comments

Comments

@jden123
Copy link

jden123 commented Mar 16, 2020

Hello!

I want to manage indexes based on index folder. I will add file based on template provided in Anytimescripts page(https://github.com/chucknorris/roundhouse/wiki/Anytimescripts).

Could you please suggest how to remove index in a good way?
Should I have file with delete index statement or I can just remove the index file?

@erikbra
Copy link
Member

erikbra commented Mar 16, 2020

This is of course a matter of preference, but I would change the script that creates the index to just check if it exists, and delete it if it does. After a while, you might delete the script altogether, of course, if you know that no deployment has the index anymore.

Say you had a script that was (SQL server syntax):

DROP INDEX IF EXISTS IX_Table_Column ON [schema].[Table] 

CREATE NONCLUSTERED INDEX [IX_Table_Column]
ON [schema].[Table] 
(
  [Column1],
  [Column2]
)
GO

I would change the script to be just:

DROP INDEX IF EXISTS IX_Table_Column ON [schema].[Table] 

And then, after a while, when you know this change has been deployed to all DBs containing the index, I would delete the file altogether.

@jden123
Copy link
Author

jden123 commented Mar 17, 2020

Thank you

@jden123 jden123 closed this as completed Mar 17, 2020
@erikbra
Copy link
Member

erikbra commented Mar 17, 2020

My pleasure :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants