Skip to content

Replace delete statements that truncate tables #209

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LaurentiuMa
Copy link

@LaurentiuMa LaurentiuMa commented Mar 14, 2025

Improves cases in which DELETE is used to remove all of the rows in a table and replaces it with TRUNCATE which improves performance as it does not scan each row individually before deletion. This also resets the identity column where applicable.

In the case where the DELETE statement outputs to a temporary table, the insert takes place before truncation.

Going forward, this would mean that a user executing this would require at least the ALTER permission rather than DELETE.

@LaurentiuMa LaurentiuMa requested a review from a team as a code owner March 14, 2025 10:04
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

Successfully merging this pull request may close these issues.

1 participant