We have this MySQL SP, which calls a nested SP. It seems it does NOT perform well under load.
It is possible that this SP becomes slow under load because it calls a nes
Yes, it's possible. We don't have measurements of how long this takes, but one can expect a temp table to cause some overhead as you create it, write data into it, query it, then drop it. How often is this being called?
Also, MySQL's stored procedures are generally known to be pretty inefficient. They don't retain the compiled form of the procedure, as they do in Oracle and other RDBMS brands. In other words, every session recompiles each procedure it uses the first time it is called.
First, I would suggest eliminating the temp table. Just design the nested procedure to build the right SQL query as a string, and return that string. Then the outer procedure executes the query is its result. You should be able to skip the create/drop of the temp table, and the insert into the temp table.
Second, if I were designing this app, I don't see any need for either stored procedure. I'd recommend writing code to build the right SQL query in your application, and then just execute that query from the application.