Skip to content

Commit

Permalink
Use ClearAndInitialize to improve performance (#8042)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasjordan authored Jan 6, 2022
1 parent 656330b commit f63915e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions functions/Get-DbaDbView.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ function Get-DbaDbView {

foreach ($db in $InputObject) {
Write-Message -Level Verbose -Message "processing $db"

# Let the SMO read all properties referenced in this command for all views in the database in one query.
# Downside: If some other properties were already read outside of this command in the used SMO, they are cleared.
$db.Views.ClearAndInitialize('', [string[]]('Name', 'Schema', 'IsSystemObject', 'CreateDate', 'DateLastModified'))

if ($fqtns) {
$views = @()
foreach ($fqtn in $fqtns) {
Expand Down

0 comments on commit f63915e

Please sign in to comment.