1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-29104 Optimize queries to INFORMATION_SCHEMA.PARAMETERS/ROUTINES

For queries like
    "SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
      WHERE SPECIFIC_NAME='proc_name'"
and
    "SELECT * FROM INFORMATION_SCHEMA.ROUTINES
      WHERE ROUTINE_NAME='proc_name'"
there is a possibility to avoid loading of the stored procedure code
and parsing it to retrieve parameters.
If the name of the procedure/function is specified explicitly then
it is possible to filter out routines that do not match at
an early stage.
This commit is contained in:
Oleg Smirnov
2022-09-19 21:36:09 +07:00
committed by Oleg Smirnov
parent 035feae610
commit d9092e3de7
5 changed files with 124 additions and 32 deletions

View File

@ -860,11 +860,11 @@ USE i_s_routines_test;
CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30)
RETURN CONCAT('XYZ, ' ,s);
#
# We cannot use the index due to CONCAT()
# We cannot use the index due to missing condition on SPECIFIC_SCHEMA,
# but we will use ROUTINE_NAME for filtering records from mysql.proc
FLUSH STATUS;
SELECT * FROM INFORMATION_SCHEMA.ROUTINES
WHERE CONCAT(ROUTINE_SCHEMA) = 'i_s_routines_test'
AND ROUTINE_NAME = 'test_func5';
WHERE ROUTINE_NAME = 'test_func5';
SPECIFIC_NAME test_func5
ROUTINE_CATALOG def
ROUTINE_SCHEMA i_s_routines_test
@ -899,7 +899,19 @@ DATABASE_COLLATION latin1_swedish_ci
SHOW STATUS LIKE 'handler_read%next';
Variable_name Value
Handler_read_next 54
Handler_read_rnd_next 55
Handler_read_rnd_next 2
#
# We cannot use the index due to CONCAT(), and filtering by ROUTINE_NAME
# does not work either since ROUTINE_NAME = 'not_existing_proc'. See
# the difference in counters in comparison to the previous test
FLUSH STATUS;
SELECT * FROM INFORMATION_SCHEMA.ROUTINES
WHERE CONCAT(ROUTINE_SCHEMA) = 'i_s_routines_test'
AND ROUTINE_NAME = 'not_existing_proc';
SHOW STATUS LIKE 'handler_read%next';
Variable_name Value
Handler_read_next 54
Handler_read_rnd_next 1
#
# Now the index must be used
FLUSH STATUS;