Skip to content
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

Get-DbaAgentJob slowness on applying DatabaseName filter #9332

Open
xshen1 opened this issue Apr 24, 2024 · 3 comments
Open

Get-DbaAgentJob slowness on applying DatabaseName filter #9332

xshen1 opened this issue Apr 24, 2024 · 3 comments
Labels
bugs life triage required New issue that has not been reviewed by maintainers

Comments

@xshen1
Copy link

xshen1 commented Apr 24, 2024

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

No errors, just lots of time spent waiting for output when we want to return job with Database filter

Steps to Reproduce

 Get-DbaAgentJob -SqlInstance sqlserver2014a -Database test_database

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

It takes around 30~40 min of each calling if we choose to apply -Database filter

Other details or mentions

            if ($Database) {
                $jobs = $jobs | Where-Object { $_.JobSteps | Where-Object DatabaseName -in $Database }
            }

this is more like n^2log(n)
wonder if we can use the first jobstep or something to reduce the filter time by a lot

What PowerShell host was used when producing this error

Windows PowerShell ISE (powershell_ise.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.17763.5576
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.5576
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Server 2019 (RTM-CU25) (KB5033688) - 15.0.4355.3 (X64)
Jan 30 2024 17:02:22
Copyright (C) 2019 Microsoft Corporation
Developer Edition (64-bit) on Windows Server 2019 Datacenter 10.0 (Build 17763: ) (Hypervisor)

.NET Framework Version

PSChildName Version


Client 4.8.03761
Full 4.8.03761
Client 4.0.0.0

@xshen1 xshen1 added bugs life triage required New issue that has not been reviewed by maintainers labels Apr 24, 2024
@wsmelton
Copy link
Member

30-40 minutes?!?!

  • How many jobs does your instance have?
  • What is the average number of steps per job on the instance?
  • How many databases does the instance have?
  • Do you get the same result in PowerShell or Windows PowerShell (don't use ISE)?

@xshen1
Copy link
Author

xshen1 commented May 16, 2024

We got like 10 job per db.
A LOT of DBs and on average 4~5 steps per job.
Yeap same result ummm

@wsmelton
Copy link
Member

wsmelton commented May 21, 2024

A LOT of DBs? Is that under 100, over 500, under 3,000? (Everyone's definition of a lot isn't the same 😉)

Be aware that if you have a large instance (once you get over ~1k databases) then the performance can play in from your master database on performance. What are the waits showing on the sessions for your scripts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs life triage required New issue that has not been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants