今天,我有一个 MySQL 存储过程,其中包含大约 20 条创建临时表语句并且没有其他任何内容。但是当我跑的时候,商店会抛出一条消息“内存不足”。
这里是商店代码:
CREATE DEFINER = 'thanhnt'@'192.168.6.31' PROCEDURE `test_out_of_memory`()
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
#SET max tmp size
SET @@tmp_table_size = 1073741824;
drop table if exists tbllogging;
create TABLE tbllogging(t TIMESTAMP, step int) ENGINE=INNODB;
DROP TABLE IF EXISTS norep_campaigntmp;
CREATE TEMPORARY TABLE `norep_campaigntmp` (
`campaignid` MEDIUMINT(9) NOT NULL DEFAULT '0' ,
`num` MEDIUMINT(9) NOT NULL DEFAULT '0'
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,0;
DROP TABLE IF EXISTS norep_campaign_NB_tmp;
CREATE TEMPORARY TABLE `norep_campaign_NB_tmp` (
`campaignid` MEDIUMINT(9) NOT NULL DEFAULT '0' ,
`num` MEDIUMINT(9) NOT NULL DEFAULT '0'
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,1;
DROP TABLE IF EXISTS norep_zonebannertmp;
CREATE TEMPORARY TABLE `norep_zonebannertmp` (
`zoneid` SMALLINT(6) NOT NULL DEFAULT '0' ,
`block` TINYINT(4) NOT NULL DEFAULT '0' ,
`location` TINYINT(4) NOT NULL DEFAULT '0' ,
`bannerid` MEDIUMINT(9) NOT NULL DEFAULT '0' ,
KEY `location` (`location`),
KEY `bannerid` (`bannerid`),
KEY `block` (`block`),
KEY `zoneid` (`zoneid`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,2;
DROP TABLE IF EXISTS norep_zonebannertmp_bk;
CREATE TEMPORARY TABLE `norep_zonebannertmp_bk` (
`zoneid` SMALLINT(6) NOT NULL DEFAULT '0' ,
`block` TINYINT(4) NOT NULL DEFAULT '0' ,
`location` TINYINT(4) NOT NULL DEFAULT '0' ,
`bannerid` MEDIUMINT(9) NOT NULL DEFAULT '0' ,
KEY `location` (`location`),
KEY `bannerid` (`bannerid`),
KEY `block` (`block`),
KEY `zoneid` (`zoneid`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,3;
DROP TABLE IF EXISTS norep_zonebanner_delete_tmp;
CREATE TEMPORARY TABLE `norep_zonebanner_delete_tmp` (
`zoneid` SMALLINT(6) NOT NULL DEFAULT '0' ,
`block` TINYINT(4) NOT NULL DEFAULT '0' ,
`location` TINYINT(4) NOT NULL DEFAULT '0' ,
`bannerid` MEDIUMINT(9) NOT NULL DEFAULT '0' ,
KEY `location` (`location`),
KEY `bannerid` (`bannerid`),
KEY `block` (`block`),
KEY `zoneid` (`zoneid`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,4;
DROP TABLE IF EXISTS norep_zonebanner_cur_tmp;
CREATE TEMPORARY TABLE `norep_zonebanner_cur_tmp` (
`zoneid` SMALLINT(6) NOT NULL DEFAULT '0' ,
`location` TINYINT(4) NOT NULL DEFAULT '0' ,
`bannerid` MEDIUMINT(9) NOT NULL DEFAULT '0' ,
KEY `location` (`location`),
KEY `bannerid` (`bannerid`),
KEY `zoneid` (`zoneid`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,5;
DROP TABLE IF EXISTS norep_grouptmp;
CREATE TEMPORARY TABLE `norep_grouptmp` (
`groupid` SMALLINT(6) NOT NULL DEFAULT '0' ,
`w` MEDIUMINT(9) NOT NULL DEFAULT '0'
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,6;
DROP TABLE IF EXISTS norep_block_delete_tmp;
CREATE TEMPORARY TABLE `norep_block_delete_tmp` (
`zoneid` INT(9) NOT NULL DEFAULT '0' ,
`location` TINYINT(4) NOT NULL DEFAULT '0' ,
`block` TINYINT(4) NOT NULL DEFAULT '0' ,
KEY `zoneid` (`zoneid`),
KEY `location` (`location`),
KEY `block` (`block`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,7;
DROP TABLE IF EXISTS norep_banner_channel_tmp;
CREATE TEMPORARY TABLE `norep_banner_channel_tmp` (
`bannerid` INT(9) NOT NULL DEFAULT '0' ,
`channelid` INT(9) NOT NULL DEFAULT '0' ,
`location` TINYINT(4) NOT NULL DEFAULT '0',
KEY `channelid` (`channelid`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,8;
DROP TABLE IF EXISTS norep_user_zone_tmp;
CREATE TEMPORARY TABLE `norep_user_zone_tmp` (
`userid` INT(9) NOT NULL DEFAULT '0' ,
`zoneid` INT(9) NOT NULL DEFAULT '0' ,
`location` TINYINT(4) NOT NULL DEFAULT '0' ,
KEY `userid` (`userid`) ,
KEY `zoneid` (`zoneid`) ,
KEY `location` (`location`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,9;
DROP TABLE IF EXISTS norep_user_zone_loc_tmp;
CREATE TEMPORARY TABLE `norep_user_zone_loc_tmp` (
`userid` INT(9) NOT NULL DEFAULT '0' ,
`zoneid` INT(9) NOT NULL DEFAULT '0' ,
`loc` TINYINT(4) NOT NULL DEFAULT '0' ,
`num` TINYINT(4) NOT NULL DEFAULT '0'
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,10;
DROP TABLE IF EXISTS norep_bannertmp_KH;
CREATE TEMPORARY TABLE `norep_bannertmp_KH` (
`campaignid` MEDIUMINT(6) NOT NULL DEFAULT '0' ,
`isexpire` MEDIUMINT(6) NOT NULL DEFAULT '0' ,
`bannerid` MEDIUMINT(6) NOT NULL DEFAULT '0' ,
KEY `bannerid` (`bannerid`) ,
KEY `campaignid` (`campaignid`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,11;
DROP TABLE IF EXISTS norep_bannertmp_NB;
CREATE TEMPORARY TABLE `norep_bannertmp_NB` (
`groupid` MEDIUMINT(6) NOT NULL DEFAULT '0' ,
`campaignid` MEDIUMINT(6) NOT NULL DEFAULT '0' ,
`bannerid` MEDIUMINT(6) NOT NULL DEFAULT '0' ,
`isexpire` MEDIUMINT(6) NOT NULL DEFAULT '0' ,
KEY `bannerid` (`bannerid`) ,
KEY `campaignid` (`campaignid`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,12;
DROP TABLE IF EXISTS norep_bannertmp1;
CREATE TEMPORARY TABLE `norep_bannertmp1` (
`groupid` INT(9) NOT NULL DEFAULT '0' ,
`userid` INT(9) NOT NULL DEFAULT '0' ,
`campaignid` INT(9) NOT NULL DEFAULT '0' ,
`bannerid` INT(9) NOT NULL DEFAULT '0' ,
`location` TINYINT(4) ,
`typegroup` TINYINT(4) DEFAULT 0 ,
`w` INT DEFAULT 0 ,
KEY `campaignid` (`campaignid`) ,
KEY `bannerid` (`bannerid`) ,
KEY `groupid` (`groupid`) ,
KEY `userid` (`userid`) ,
KEY `location` (`location`) ,
KEY `typegroup` (`typegroup`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,13;
DROP TABLE IF EXISTS norep_101_tmp;
CREATE TEMPORARY TABLE `norep_101_tmp` (
`userid` INT ,
`bannerid` INT ,
`ctr` decimal(6,3) NOT NULL,
`views` INT ,
KEY `userid` (`userid`) ,
KEY `bannerid` (`bannerid`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,14;
DROP TABLE IF EXISTS norep_banner_zone_in;
CREATE TEMPORARY TABLE `norep_banner_zone_in` (
`channelid` INT ,
`zoneid` INT ,
`location` TINYINT(4) ,
`bannerid` INT ,
`CTR` DECIMAL(6,3) ,
`money` INT,
KEY `channelid` (`channelid`) ,
KEY `zoneid` (`zoneid`) ,
KEY `bannerid` (`bannerid`) ,
KEY `location` (`location`)
)ENGINE=MYISAM;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,15;
DROP TABLE IF EXISTS norep_banner_zone_no_gen_tmp;
CREATE TEMPORARY TABLE `norep_banner_zone_no_gen_tmp` (
`zoneid` INT ,
`location` TINYINT(4) ,
`bannerid` INT ,
`userid` INT ,
KEY `userid` (`userid`) ,
KEY `zoneid` (`zoneid`) ,
KEY `bannerid` (`bannerid`) ,
KEY `location` (`location`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,16;
DROP TABLE IF EXISTS norep_banner_zone_no_gen_tmp1;
CREATE TEMPORARY TABLE `norep_banner_zone_no_gen_tmp1` (
`zoneid` INT ,
`location` TINYINT(4) ,
`bannerid` INT ,
`userid` INT ,
KEY `userid` (`userid`) ,
KEY `zoneid` (`zoneid`) ,
KEY `bannerid` (`bannerid`) ,
KEY `location` (`location`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,17;
DROP TABLE IF EXISTS norep_banner_zone_no_gen_today_tmp;
CREATE TEMPORARY TABLE `norep_banner_zone_no_gen_today_tmp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`zoneid` INT ,
`location` TINYINT(4) ,
`bannerid` INT ,
`userid` INT ,
KEY `id` (`id`) ,
KEY `userid` (`userid`) ,
KEY `zoneid` (`zoneid`) ,
KEY `bannerid` (`bannerid`) ,
KEY `location` (`location`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,18;
DROP TABLE IF EXISTS norep_banner_zone_no_gen_today_tmp1;
CREATE TEMPORARY TABLE `norep_banner_zone_no_gen_today_tmp1` (
`id` int(11) NOT NULL,
`zoneid` INT ,
`location` TINYINT(4) ,
`bannerid` INT ,
`userid` INT ,
KEY `id` (`id`) ,
KEY `userid` (`userid`) ,
KEY `zoneid` (`zoneid`) ,
KEY `bannerid` (`bannerid`) ,
KEY `location` (`location`)
)ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,19;
DROP TABLE IF EXISTS norep_ssv_tmp;
CREATE TEMPORARY TABLE `norep_ssv_tmp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userid` int(11) unsigned NOT NULL,
`bannerid` int(11) unsigned NOT NULL,
`money` int(11) unsigned NOT NULL,
`ctr` decimal(6,3) NOT NULL,
`createtime` datetime DEFAULT NULL,
`typegroup` tinyint(4) NOT NULL DEFAULT '0' ,
KEY `id` (`id`) ,
KEY `typegroup` (`typegroup`) ,
KEY `userid` (`userid`)
) ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,20;
DROP TABLE IF EXISTS norep_ssv_tmp1;
CREATE TEMPORARY TABLE `norep_ssv_tmp1` (
`id` int(11) NOT NULL,
`userid` int(11) unsigned NOT NULL,
`bannerid` int(11) unsigned NOT NULL,
`money` int(11) unsigned NOT NULL,
`ctr` decimal(6,3) NOT NULL,
`createtime` datetime DEFAULT NULL,
`typegroup` tinyint(4) NOT NULL DEFAULT '0' ,
KEY `typegroup` (`typegroup`) ,
KEY `userid` (`userid`)
) ENGINE=INNODB;
INSERT INTO tbllogging SELECT CURRENT_TIMESTAMP,21;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
INSERT INTO tbllogging select CURRENT_TIMESTAMP, 22;
SELECT * FROM tbllogging;
END;
MySQL 5.5 内存:48 GB
任何想法?