Skip to content

Invoke-DbaDbDataMasking - Improve performance #9671

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 1 commit into
base: development
Choose a base branch
from

Conversation

AdamJKoehler
Copy link
Contributor

@AdamJKoehler AdamJKoehler commented May 16, 2025

Switch from column-based masking to row-based masking.

Type of Change

  • Bug fix (non-breaking change, fixes Invoke-DbaDbDataMasking - Poor performance  #7940 )
  • New feature (non-breaking change, adds functionality, fixes # )
  • Breaking change (affects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (Invoke-ManualPester)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/dataplat/appveyor-lab ?
  • Unit test is included
  • Documentation
  • Build system

Purpose

To improve the speed at which Invoke-DbaDbDataMasking masks data in large tables

Approach

This change switches from Column by column masking to row by row masking, allowing for a batch of rows to be done at a single time, instead of having to iterate over each column to be masked in the table for each row.

Switch from column-based masking to row-based masking.
$uniqueData = Invoke-DbaQuery -SqlInstance $server -SqlCredential $SqlCredential -Database tempdb -Query $query
} catch {
Stop-Function -Message "Something went wrong getting the unique data" -Target $query -ErrorRecord $_
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why using "continue" here (you could use the -Continue parameter of Stop-Function) and "return" a few rows later? We need a general way to handle errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a look at that and get it worked out the other way.

@andreasjordan
Copy link
Contributor

This is a big change and not easy to review. Best would be to let @sanderstad have a look at this and approve it. Sander, do you have the time?

@andreasjordan
Copy link
Contributor

As #9664 is merged, you should update your branch to resolve the conflict. Then we can continue to review this PR.

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.

Invoke-DbaDbDataMasking - Poor performance
2 participants