Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.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
在mysql中并发执行存储过程_Mysql_Sql - Fatal编程技术网

在mysql中并发执行存储过程

在mysql中并发执行存储过程,mysql,sql,Mysql,Sql,我在mysql工作。我有一个需要1分钟运行的存储过程。我必须用不同的参数运行这个过程10次。如何使用不同的参数同时运行过程的10个实例?我的过程是这样的,任何两个实例之间都不会发生锁定 如果您使用的是Linux,那么一个解决方案就是创建shell脚本,并在特定时间将其作为cron作业运行。下面是一个示例shell脚本。此脚本名为sql1.sh,它将当前日期写入out1.txt #!\bin\bash date > out1.txt 因此,我将sql1.sh设置为sql5.sh,并将输出写

我在mysql工作。我有一个需要1分钟运行的存储过程。我必须用不同的参数运行这个过程10次。如何使用不同的参数同时运行过程的10个实例?我的过程是这样的,任何两个实例之间都不会发生锁定

如果您使用的是Linux,那么一个解决方案就是创建shell脚本,并在特定时间将其作为cron作业运行。下面是一个示例shell脚本。此脚本名为sql1.sh,它将当前日期写入out1.txt

#!\bin\bash
date > out1.txt
因此,我将sql1.sh设置为sql5.sh,并将输出写入out1.txt,直到out5.txt

Mon Feb 4 19:37:01 UTC 2019 - out1.txt
Mon Feb 4 19:37:01 UTC 2019 - out2.txt
Mon Feb 4 19:37:01 UTC 2019 - out3.txt
Mon Feb 4 19:37:01 UTC 2019 - out4.txt
Mon Feb 4 19:37:01 UTC 2019 - out5.txt

下面是在19:37执行shell脚本的crontab文件

37 19 * * * /yourDirectory/sql1.sh
37 19 * * * /yourDirectory/sql2.sh
37 19 * * * /yourDirectory/sql3.sh
37 19 * * * /yourDirectory/sql4.sh
37 19 * * * /yourDirectory/sql5.sh
这是从out1.txt到out5.txt的输出

Mon Feb 4 19:37:01 UTC 2019 - out1.txt
Mon Feb 4 19:37:01 UTC 2019 - out2.txt
Mon Feb 4 19:37:01 UTC 2019 - out3.txt
Mon Feb 4 19:37:01 UTC 2019 - out4.txt
Mon Feb 4 19:37:01 UTC 2019 - out5.txt


因此,不要使用date命令,而是使用具有适当选项的mysql来运行sql查询。这可能效率不高,但可以完成工作

创建10个会话(连接)并在每个会话中运行一次?也许您需要一个批处理文件。请看这里:@kristech“&”表示在第一个命令执行后运行第二个命令。我希望所有命令同时/并行运行。是否有脚本语言可用于将其打包?它们通常可以使用多个连接/线程运行并行查询。如果不是,您将需要N个并行进程来处理N个并发查询。我可以使用jmeter工具吗?