-
-
Notifications
You must be signed in to change notification settings - Fork 857
Description
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
Summary
When using Get-DbaDbTable with -Schema and -Table parameters to retrieve a single specific table, version 2.7.7 queries metadata for ALL tables in the database before filtering client-side. This causes a massive performance regression compared to version 2.7.6, which correctly filters server-side.
Environment
dbatools version (broken): 2.7.7
dbatools version (working): 2.7.6
SQL Server version: 2016 (MSSQL13)
PowerShell version: 5.1 / 7.x
Steps to Reproduce
Test command
Measure-Command {
$result = Get-DbaDbTable -SqlInstance $server -Database "MyDatabase" -Schema "dispo" -Table "t_auftraege"
}
Expected Behavior
The command should complete in under 1 second by filtering on schema and table name in the SQL query sent to the server.
Actual Behavior
Version 2.7.6: Completes in < 1 second ✅
Version 2.7.7: Takes ~30 seconds ❌
Please confirm that you are running the most recent version of dbatools
The problem is also with version 2.7.23 but I wanted to nail down where the problem first appeared.
Other details or mentions
Version 2.7.6 Behavior (Correct)
Only queries the necessary system tables with proper WHERE clause filtering:
sys.databases
sys.tables (filtered by schema and name)
Minimal system catalog queries
Version 2.7.7 Behavior (Regression)
Retrieves metadata for every single table in the database:
Queries sys.tables for ALL 1,150 tables
Queries sys.partitions to get RowCount for EACH table
Retrieves data from 18 different schemas (dispo, plinfo, pld, wtv, global, medien, dbo, etc.)
Filters results client-side AFTER retrieving everything
Evidence from Trace Analysis
Tables queried in 2.7.7 that should NOT be queried when requesting only dispo.t_auftraege:
- 268 tables from schema 'dispo'
- 239 tables from schema 'plinfo'
- 196 tables from schema 'pld'
- 87 tables from schema 'wtv'
- 84 tables from schema 'global'
- 68 tables from schema 'medien'
- ... and many more
Impact
Commands that took < 1 second now take 30+ seconds
Significantly increased load on SQL Server
Poor user experience for databases with many tables
Makes the -Schema and -Table parameters essentially useless for performance
Suggested Fix
The -Schema and -Table parameters should be incorporated into the SQL WHERE clause before querying the server, not used for client-side filtering after retrieving all data.
Workaround
Downgrade to version 2.7.6:
Install-Module dbatools -RequiredVersion 2.7.6 -Force
Attachments
SQL Server Profiler trace files are available upon request.
Soll ich noch etwas hinzufügen oder anpassen?
Impact
Commands that took < 1 second now take 30+ seconds
Significantly increased load on SQL Server
Poor user experience for databases with many tables
Makes the -Schema and -Table parameters essentially useless for performance
Suggested Fix
The -Schema and -Table parameters should be incorporated into the SQL WHERE clause before querying the server, not used for client-side filtering after retrieving all data.
Workaround
Downgrade to version 2.7.6:
What PowerShell host was used when producing this error
Windows PowerShell (powershell.exe), PowerShell Core (pwsh.exe)
PowerShell Host Version
Name Value
PSVersion 7.5.4
PSEdition Core
GitCommitId 7.5.4
OS Microsoft Windows 10.0.26200
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
SQL Server Edition and Build number
SQL Server version: 2016 (MSSQL13)
.NET Framework Version
.NET 9.0.10