Invoke-SqlCmd2 icon indicating copy to clipboard operation
Invoke-SqlCmd2 copied to clipboard

Slowness on import caused by first line of Invoke-SqlCmd2.ps1

Open potatoqualitee opened this issue 8 years ago • 5 comments

image

potatoqualitee avatar Feb 17 '17 00:02 potatoqualitee

per @FriedrichWeinmann : Measure-Command { Get-Item function:\Invoke-Sqlcmd2 -ErrorAction Ignore }

image

potatoqualitee avatar Feb 17 '17 00:02 potatoqualitee

Strange! I can't seem to replicate this. It could be related to this, and I've seen AV add to this.

Any chance you could swap in Bartek's method for loading functions into the psm1 to see if this resolves the issue? Otherwise, I'm happy to just make the change (PR in dbatools dev branch, pull back here?)

On that note / aside, I'll open another issue on a process for automating that, if it makes sense:

  • dbatools appveyor job runs
  • tests run, if they pass...
  • clone this repo
  • replace invoke-sqlcmd.ps1, git add, git commit (re-use commit message from dbatools push), git push

SSH key or some other auth can be stored in AppVeyor secure variables, if you're comfortable with that. Or... AppVeyor might already be running with that permission? Not sure!

Cheers!

RamblingCookieMonster avatar Feb 17 '17 02:02 RamblingCookieMonster

Hi Warren, we already use that method of loading files. This delay on Get-Command happens, when the command isn't available only. Cheers, Fred

FriedrichWeinmann avatar Feb 17 '17 07:02 FriedrichWeinmann

Gotcha - I left in some cruft that might be slowing things down - removing the bit that searches a non-existent private folder cuts down the speed for me from 800ms to 100ms or so.

Still can't duplicate a two second delay though, could something else be in play on your system (anti-malware software, for example)?

RamblingCookieMonster avatar Feb 17 '17 13:02 RamblingCookieMonster

Hey Warren, Not sure about the dela -- I use the default Microsoft malware stuff.

The appveyor thing sounds good :) Right now, I'm just putting it in the manual publish.ps1 that I have LOL.

Lemme know when that cruft has been removed (or where I can remove it) -- I'd love to include the speed up in the upcoming release.

potatoqualitee avatar Feb 17 '17 15:02 potatoqualitee