SQLPS选项卡扩展(选项卡完成)太慢,完全无法使用。我的配置有问题吗?我是否应该以某种方式升级到更晚的版本?有什么解决办法可以让它有用吗?
相关版本信息:
发布于 2013-06-19 14:18:01
据我所知,性能问题实际上是在SqlServer psprovider中解决路径的实现中。解析路径是TabExpansion的默认实现(在Powershell v2中)是如何完成路径的。
我能够通过重写TabExpansion函数来解决这个问题,使用Get和Where来代替解析路径。你可以在bitbucket回购中找到最新的实现。
下面是当前的实现:
function TabExpansion($line, $lastWord) {
if (!((get-location).Provider.Name -eq "SqlServer")) {
TabExpansionSqlPsBackup $line $lastWord
}
else {
$index = $lastWord.LastIndexOfAny(@('\', '/'))
if ($index -gt -1) {
$parent = $lastWord.substring(0, $index+1)
$leaf = $lastWord.substring($index+1)
}
else {
$parent = ""
$leaf = $lastWord
}
$matches = ls -path $parent | ?{ $_.PSChildName -match "^$leaf" }
if ($matches) {
$matches | %{ $parent + $_.PSChildName }
}
else {$lastWord}
}
}将该函数放在位于~\Documents\WindowsPowerShell\Microsoft.SqlServer.Management.PowerShell.sqlps_profile.ps1的sqlps配置文件中
https://stackoverflow.com/questions/17193489
复制相似问题