Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql psql启动多个并发.sql脚本并限制进程_Postgresql_Powershell_Psql - Fatal编程技术网

Postgresql psql启动多个并发.sql脚本并限制进程

Postgresql psql启动多个并发.sql脚本并限制进程,postgresql,powershell,psql,Postgresql,Powershell,Psql,背景: 操作系统Win10 postgresql 9.6 postgis 2.5 故事: 我在win文件夹中有200个带有postgres(st_union函数)查询的.slq脚本。 我可以运行一个“for%%f in(*.sql)do(start cmd/c“psql-U postgres-f”%%f“abn2030”)。在这些文件上并行运行bat,我的8个内核有一些素材。 除了200个脚本太多。我正在寻找一种方法来限制运行的'cmd'/'psql'实例。我想检查cmd(或psql)的实例是否

背景: 操作系统Win10 postgresql 9.6 postgis 2.5

故事: 我在win文件夹中有200个带有postgres(st_union函数)查询的.slq脚本。 我可以运行一个“for%%f in(*.sql)do(start cmd/c“psql-U postgres-f”%%f“abn2030”)。在这些文件上并行运行bat,我的8个内核有一些素材。 除了200个脚本太多。我正在寻找一种方法来限制运行的'cmd'/'psql'实例。我想检查cmd(或psql)的实例是否正在运行,并启动下一个(排队等待)。只有当cmd/psql的实例数小于15时,才使用sql脚本。(如果这有道理,也许还有其他选择)。 我尝试了powershell和python(在较小的范围内),但我不知道应该使用哪种(如果有的话)

powershell: 直接运行。脚本执行时没有问题

cmd /c ""C:\PostgreSQL\9.6\bin\psql.exe" -U postgres -d db -f "D:\Dropbox\scripts_sql\execute_htunion\pwshl\queries1.SQL""
剧本:(大部分是从另一篇文章中偷来的)

输出:psql:FATAL:role“postgres-fd:\Dropbox\scripts\u sql\execute\u htunion\pwshl\query”不存在

如何在powershell(或其他语言)中发送psql命令中的start.sql

编辑:
在.bat中解决,使用: “C:\Program Files\Git\bin\sh.exe”-login-i-C“find.-iname'*.sql'-print0 | xargs--null--max procs=14-i{}psql.exe-U postgres-d db-f{}”应该具有和,这是Linux源命令,串联起来非常适合执行此任务:

find . -name '*.sql' -print0 \
| xargs --null --max-procs=16 -I{} psql.exe -U postgres -d db -f {}
find . -name '*.sql' -print0 \
| xargs --null --max-procs=16 -I{} psql.exe -U postgres -d db -f {}