set tmp_table_size=10*1024*1024*1024; set max_heap_table_size=10*1024*1024*1024; CREATE TABLE t1 (a CHAR(129) BINARY, b INT, KEY USING HASH (a)) engine=memory; INSERT INTO t1 VALUES ('1',1),('2',2),('3',3),('4',4); INSERT INTO t1 SELECT a, b + 4 from t1; INSERT INTO t1 SELECT a, b + 8 from t1; INSERT INTO t1 SELECT a, b + 16 from t1; INSERT INTO t1 SELECT a, b + 32 from t1; INSERT INTO t1 SELECT a, b + 64 from t1; INSERT INTO t1 SELECT a, b + 128 from t1; INSERT INTO t1 SELECT a, b + 256 from t1; INSERT INTO t1 SELECT a, b + 512 from t1; INSERT INTO t1 SELECT a, b + 1024 from t1; INSERT INTO t1 SELECT a, b + 2048 from t1; INSERT INTO t1 SELECT a, b + 4096 from t1; INSERT INTO t1 SELECT a, b + 8192 from t1; INSERT INTO t1 SELECT a, b + 16384 from t1; INSERT INTO t1 SELECT a, b + 32768 from t1; INSERT INTO t1 SELECT a, b + 65536 from t1; INSERT INTO t1 SELECT a, b + 131702 from t1; DELIMITER |; CREATE PROCEDURE p1(inx INTEGER) BEGIN DECLARE res INTEGER; WHILE inx > 0 DO SELECT count(*) into res from t1 where a = 'b'; SET inx = inx - 1; END WHILE; END| DELIMITER ;| --start_timer CALL p1(1500000); --end_timer