Yes, if compared to code in Java or C#. For example, this overly simple code took 284 seconds.
CREATE PROCEDURE CountTest()
declare counter int default 0;
set counter = counter + 1;
until counter > 120000000
Ignoring my off by one error, here is equivalent code in C# (the language I’m currently learning). It took 419 milliseconds, or MySQL took 677 times longer to execute. From my experience, Java isn’t going to be any slower.
int counter = 0;
while (counter < 120000000)
Slow stored procedure performance is one of the reasons why it usually isn’t wise to implement computationally expensive business logic in the database. With networks not being the bottleneck they once were it is often better to extract the data to the application layer and process it in the programming language of your choice, even if that takes a few extra round trips to the database. There are exceptions where those extra round trips are too numerous and prohibitively expensive. With something as complex as a database there are always exceptions.
This example is a bit too simple, but, based on experience, it is representative of the general performance of stored procedure logic.
How can MySQL get away with such poor performance? Well, the equivalent code in MS SQL Server took 80 seconds on the same hardware, which is also two orders of magnitude slower than C# or Java code.
create procedure testCount
declare @countNo int;
set @countNo = 0;
while (@countNo < 120000000)
set @countNo = @countNo + 1
MS SQL Server code runs 3.5 times faster than MySQL, but given how much older MS SQL Server is, MySQL is doing well here. So are MySQL Stored procedures slow? Not really, if compared to other databases I’ve used.
Just don’t use them to do computationally expensive business logic.