Some ideas regarding to database performance (General)
(my skill does not reach up to yours, but i do my best...)
the combination of
Hoster: IONOS Germany
DB: MariaDB 10.6
and this php script as a dummy test:
$xtext="CREATE PROCEDURE Test5 ()
SQL SECURITY DEFINER
select count(*) from mlf2_settings;
works to create a SP.
I put an include at the end of includes/admin.inc.php (just before th subtemplate is called)
$result = mysqli_query($connid, $xtext);
Using phpmyadmin shows syntax differences between php and the frontend of phpmyadmin.
Testing SQL code in phpmyadmin, you have to use the Delimiter field below of the input field.
Works, but only for testing.