Bug #119232 concept of concurrent execution for complex stored procedures
Submitted: 24 Oct 2025 15:11
Reporter: Alex Zimnitski Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[24 Oct 2025 15:11] Alex Zimnitski
Description:
Currently, all queries within the stored procedure are executed sequentially.

For complex procedures, response time can be reduced by executing some queries in parallel.

The primary criterion for parallelization is the absence of dependencies between queries—specifically, modifications to variable or table values (e.g., by triggers).

This can be achieved in two ways:
1. by analyzing subsequent queries and building a dependency graph
2. using optimizer hints

Additionally, a parameter can be introduced to limit the number of concurrent threads.

How to repeat:
CREATE PROCEDURE parallel_test( IN a1 int unsigned )
BEGIN

	DECLARE	v1,v2,v3,v4,v5 int unsigned;
	
	/*PARALLELISM BLOCK START*/
	
	/*P_THREAD_1*/
	SELECT COUNT(*) INTO v1 FROM t1;
	
	/*P_THREAD_2*/
	SELECT COUNT(*) INTO v2 FROM t2;
	
	/*P_THREAD_3*/
	SELECT COUNT(*) INTO v3 FROM t3;

	/*P_THREAD_4*/
	SELECT COUNT(*) INTO v4 FROM t1 WHERE t1.t=1;

	/*PARALLELISM BLOCK END - WAIT THREADS*/
	
	SET v5 = v1 + v2 + v3 + v4;

	/*PARALLELISM BLOCK START*/

	/*P_THREAD_1*/
	UPDATE t1 SET
		t1.tt = v5;
	WHERE t1.id = a1
	LIMIT 1;

	/*P_THREAD_2*/
	SELECT v5;

	/*PARALLELISM BLOCK END - WAIT THREADS*/
	
END