Answer the question
In order to leave comments, you need to log in
MySQL Stored Procedures and Limits?
Faced a small problem: There is a stored procedure consisting of SELECT.
It is necessary to receive data only in certain ranges (not known in advance).
But the problem is that LIMIT in a stored procedure does not accept variables as its parameters.
What can be used instead? Or how to solve this problem, preferably without loss of performance.
And the second question: Strange behavior of stored procedures (with static SQL commands). If you make a regular SELECT query, then it runs in 0.000013 seconds, and if you make the same query, but wrapped in a stored procedure, then the execution time is 0.000510. those. a wild loss of performance, although in fact it should be the other way around, because:
Answer the question
In order to leave comments, you need to log in
“The server does not need to parse a complex request, because stored procedures are stored in an already compiled form with an already configured data sampling scheme ”...
All procedures are a program that switches the context. A simple skvl query = it works SQL, there is a parser, then an optimizer, etc.
It’s not so simple in procedurals, you need to call (albeit a compiled procedural) there, it still contains SQL that needs to be processed and finally somewhere then send somewhere that returned SELECT.
Shorter brakes in context switching between SQL and PL. For simple things, just use SQL.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question