dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Set-DbaDbCompression always compresses all materialized Views in DB

Open ft3411 opened this issue 3 years ago • 5 comments

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

When using set-dbadbcompression and specifying one or more tables: The tables and indexes are compressed as expected. After that the script iterates through all Views in the the database compresses them as well. See set-dbadbcompression.ps1 line 286: foreach ($index in $($server.Databases[$($db.name)].Views | Where-Object { $_.Indexes }).Indexes)

Thank you for your help -tom

Steps to Reproduce

Set-DbaDbCompression -SqlInstance 'server100' -Database 'DB000' -Table 'Fancytable1' -CompressionType Page

Please confirm that you are running the most recent version of dbatools

tested with 1.1.132

Other details or mentions

No response

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

This happens in Windows Powershell and pwsh as well.

SQL Server Edition and Build number

SQL Server 2019 Enterprise Edition

.NET Framework Version

.NET Framework 4.7.3946.0

ft3411 avatar Sep 15 '22 07:09 ft3411

Thanks for the report, tom! @jpomfret any chance you can take a look?

potatoqualitee avatar Sep 15 '22 07:09 potatoqualitee

Oh good thought, I'll take a look into that for you. Thanks for the report.

(Probably not for a week though as I just went on holiday - will set a reminder for when I'm back!)

jpomfret avatar Sep 16 '22 04:09 jpomfret

Enjoy 🌴 🏖️ !

potatoqualitee avatar Sep 16 '22 07:09 potatoqualitee

This got a bit stale. So let me bring this issue to you attention again...

andreasjordan avatar Jun 10 '23 14:06 andreasjordan

I see two options here:

  • We can take the parameters and the documentation as set and just remove the code in lines 285 to 325.
  • We add a new parameter -View and filter the views to process based on that parameter.

I can help coding if needed.

andreasjordan avatar Jun 22 '23 13:06 andreasjordan