MySQL 5.6 MRR的存储过程完美诠释_MySQL
程序员文章站
2022-06-17 22:35:46
...
bitsCN.com
MySQL 5.6 MRR的存储过程完美诠释 MySQL 5.6 即将发布, 5.6对优化器方面做了诸多优化。 我这次主要解释MRR(MULTI-RANGE-READ)。 我用存储过程解释了这一过程的改变。大家细心体会去吧。我们针对语句:[sql] select log_time from person where nick_name = 'Lucy'; 表结构为:[sql] CREATE TABLE `person` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `nick_name` varchar(40) NOT NULL, `log_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `idx_nick_name` (`nick_name`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 首先是MySQL 5.5.[sql] DELIMITER $$ USE `ytt`$$ DROP PROCEDURE IF EXISTS `sp_range_scan5_5`$$ CREATE DEFINER=`admin`@`%` PROCEDURE `sp_range_scan5_5`() BEGIN -- Sample sql statement is below. -- select log_time from person where nick_name = 'Lucy'; DECLARE i INT UNSIGNED DEFAULT 0; DECLARE cnt INT UNSIGNED DEFAULT 0; SET @result = ''; SELECT COUNT(1) INTO cnt FROM person WHERE nick_name = 'Lucy'; loop1:WHILE i bitsCN.com
MySQL 5.6 MRR的存储过程完美诠释 MySQL 5.6 即将发布, 5.6对优化器方面做了诸多优化。 我这次主要解释MRR(MULTI-RANGE-READ)。 我用存储过程解释了这一过程的改变。大家细心体会去吧。我们针对语句:[sql] select log_time from person where nick_name = 'Lucy'; 表结构为:[sql] CREATE TABLE `person` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `nick_name` varchar(40) NOT NULL, `log_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `idx_nick_name` (`nick_name`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 首先是MySQL 5.5.[sql] DELIMITER $$ USE `ytt`$$ DROP PROCEDURE IF EXISTS `sp_range_scan5_5`$$ CREATE DEFINER=`admin`@`%` PROCEDURE `sp_range_scan5_5`() BEGIN -- Sample sql statement is below. -- select log_time from person where nick_name = 'Lucy'; DECLARE i INT UNSIGNED DEFAULT 0; DECLARE cnt INT UNSIGNED DEFAULT 0; SET @result = ''; SELECT COUNT(1) INTO cnt FROM person WHERE nick_name = 'Lucy'; loop1:WHILE i bitsCN.com
上一篇: PHP分页种