bjk116
bjk116

Reputation: 529

Does MySQL Queue Stored Procedure calls?

I have a stored procedure sp_performArchive() which calls another stored procedure multiple times. Like so -

CREATE DEFINER=`root`@`%` PROCEDURE `sp_performarchive`()
BEGIN
CALL sp_archive2('pallets', 4);
CALL sp_archive2('cases', 4);
CALL sp_archive2('prepacks', 4);
CALL sp_archive2('bottles', 4);
END

I am having some oddities in my data, which would be explainable if they these sp_archive2's were running concurrently. Is that the case here? Does MySQL try to run them all at once? Or are they put into a queue?

I am using MySQL 5.6.

Upvotes: 0

Views: 177

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562348

Each MySQL session is single-threaded, so there's no way one session can run those stored procedures in parallel. The statements in a procedure are executed serially.

You can still have race conditions, but it could happen only if you run the procedures in more than one session.

Upvotes: 1

Related Questions