问题:我有大量的SQL查询(大约10k-20k),并且我想在50个(或更多)线程中异步运行它们。
我为此工作编写了一个powershell脚本,但是它非常慢(执行所有操作大约需要20个小时)。期望的结果是最多3-4小时。
问题:如何优化此Powershell脚本?我应该重新考虑和使用其他技术,如python
或c#
?
我认为这是powershell的问题,因为当我检查whoisactive
查询时,它们执行得很快。创建,退出和卸载作业需要花费大量时间,因为为每个线程创建了单独的PS实例。
我的代码:
$NumberOfParallerThreads = 50;
$Arr_AllQueries = @('Exec [mystoredproc] @param1=1, @param2=2',
'Exec [mystoredproc] @param1=11, @param2=22',
'Exec [mystoredproc] @param1=111, @param2=222')
#Creating the batches
$counter = [pscustomobject] @{ Value = 0 };
$Batches_AllQueries = $Arr_AllQueries | Group-Object -Property {
[math]::Floor($counter.Value++ / $NumberOfParallerThreads)
};
forEach ($item in $Batches_AllQueries) {
$tmpBatch = $item.Group;
$tmpBatch | % {
$ScriptBlock = {
# accept the loop variable across the job-context barrier
param($query)
# Execute …
Run Code Online (Sandbox Code Playgroud) sql parallel-processing powershell multithreading asynchronous
我正在使用库中的函数来处理非常大的单词文件,我无法更改此功能.在处理时,我想显示一个进度条,因为无论哪种方式,应用程序看起来都冻结了,用户也不知道它实际上正在工作.现在我正在使用这样的工人:
private void btnClick(object sender, RoutedEventArgs e)
{
BackgroundWorker worker = new BackgroundWorker();
worker.RunWorkerCompleted += worker_RunWorkerCompleted;
worker.WorkerReportsProgress = true;
worker.DoWork += worker_DoConvertOne;
worker.ProgressChanged += worker_ProgressChanged;
worker.RunWorkerAsync();
}
private void worker_DoConvertOne(object sender, DoWorkEventArgs e)
{
var worker = sender as BackgroundWorker;
//The progress bar is filled on 20%
worker.ReportProgress(0);
worker.ReportProgress(10);
worker.ReportProgress(20);
//Processing
myLongLastingFunction(bigWordFile);
//The progress bas is full
worker.ReportProgress(100, "Done Processing.");
}
private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
MessageBox.Show("Converting finished!");
TestProgressBar.Value = 0;
ProgressTextBlock.Text = "";
}
private void worker_ProgressChanged(object …
Run Code Online (Sandbox Code Playgroud) 我有以下问题:在 Mozilla Firefox 中,每当我将a悬停dropdown
在表格内时,它都会触发mouseleave
表格事件,尽管鼠标光标仍在表格内。在 Chrome 或 Edge 中没有这样的问题。
这是我的带有示例数据的代码:
我有一个表格,当鼠标光标进入表格时,最后一行出现。当鼠标离开 - 行隐藏。只有当我离开桌子时,该行才应该隐藏
是否有某种方法或解决方法可以防止发生不必要的 mouseleave 事件?
我是编程新手,所以如果我的问题看起来很愚蠢,我很抱歉。我想问一下,Multi.Dictionary
当我有值时,是否有任何方法可以返回键?
这是我的代码:
Dim myDict
Set myDict= Server.CreateObject("Multi.Dictionary")
myDict.UniqueKeys = False
'Fill dictionary with some data
myDict("param1") = "value1"
myDict.Add "param2", "value2"
myDict.Add "param2", "value2.2"
'Get dictionary Keys
Keys = myDict.Keys
Items = myDict.Items
For Z = 0 To UBound(Items)
Response.Write(Keys(Z) & " " & Items(Z) & "<br>")
Next
Run Code Online (Sandbox Code Playgroud)
现在返回
下标超出范围:'2'
这是正常的,因为我循环了 3 次而我只有 2 个键。
那么是否有可能得到这样的结果:
参数 1:“值 1” 参数 2:“值 2” 参数 2:“value2.2”
我想从给定的 2 个对象生成 HTML 表,但它有太多嵌套的标题,我似乎无法管理。
最终结果如下:
这是我创建表格时获得的数据:
var columnData = [ {Col001: "1",Col002: "John Barnes",Col003: "Martha Hall",Col004: "Small",Col005: "Has a Drive-Thru",Col006: "Dustin Kensrue", ScorePct: "84.7"},
{Col001: "2",Col002: "John Barnes",Col003: "Martha Hall",Col004: "Small",Col005: "Has a Drive-Thru",Col006: "Dustin Kensrue", ScorePct: "93.8"},
{Col001: "2",Col002: "John Barnes",Col003: "Martha Hall",Col004: "Small",Col005: "Has a Drive-Thru",Col006: "Ninja Koto", ScorePct: "87.5"},
{Col001: "3",Col002: "Russell Montgomery",Col003: "Judith Rodriguez",Col004: "Small",Col005: "Has a Drive-Thru",Col006: "Dustin Kensrue", ScorePct: "90.3"},
{Col001: "4",Col002: "Russell Montgomery",Col003: "Judith Rodriguez",Col004: "Small",Col005: "Has a Drive-Thru",Col006: "Ninja Koto", ScorePct: …
Run Code Online (Sandbox Code Playgroud) javascript ×2
asp-classic ×1
asynchronous ×1
c# ×1
dictionary ×1
events ×1
firefox ×1
html-table ×1
jquery ×1
json ×1
mouseleave ×1
object ×1
pivot-table ×1
powershell ×1
progress-bar ×1
sql ×1
vbscript ×1
wpf ×1