首先感谢ACMAIN_CHM 在以往帖子中的所有帮助
结了所有的帖子重开一贴
在运行存储过程的时候出现这个问题
调试成功,但是运行出错
mysql> call MsgContent_pro//
ERROR 1206 (HY000): The total number of locks exceeds the lock table size
mysql>
关键的两个参数修改为
innodb_buffer_pool_size=800M
max_write_lock_count 是4294967295 附我的存储过程(再谢ACMAIN_CHM )
mysql> delimiter //
mysql>
mysql> create procedure MsgContent_pro ()
-> begin
-> repeat
-> update tbContent
-> set msgID=( select mi from (select msgContent,max(msgID) as ma,min(msgID) as mi
-> from tbMsgContent
-> group by msgContent
-> having count(msgContent)>=2
-> ) c where ma=tbContent.msgID)
-> where msgID in (select ma from (select msgContent,max(msgID) as ma,min(msgID) as mi
-> from tbMsgContent
-> group by msgContent
-> having count(msgContent)>=2
-> ) c )
-> order by tbContent.msgID
-> limit 100;
-> until row_count()=0 end repeat;
-> delete a from tbMsgContent a inner join tbMsgContent b
-> on a.msgContent=b.msgContent and a.msgID>b.msgID;
-> end;
->
-> //
Query OK, 0 rows affected (0.01 sec)mysql>
mysql> delimiter ;
mysql> call MsgContent_pro();
Query OK, 0 rows affected (0.06 sec)mysql>怎么解决,拜谢
结了所有的帖子重开一贴
在运行存储过程的时候出现这个问题
调试成功,但是运行出错
mysql> call MsgContent_pro//
ERROR 1206 (HY000): The total number of locks exceeds the lock table size
mysql>
关键的两个参数修改为
innodb_buffer_pool_size=800M
max_write_lock_count 是4294967295 附我的存储过程(再谢ACMAIN_CHM )
mysql> delimiter //
mysql>
mysql> create procedure MsgContent_pro ()
-> begin
-> repeat
-> update tbContent
-> set msgID=( select mi from (select msgContent,max(msgID) as ma,min(msgID) as mi
-> from tbMsgContent
-> group by msgContent
-> having count(msgContent)>=2
-> ) c where ma=tbContent.msgID)
-> where msgID in (select ma from (select msgContent,max(msgID) as ma,min(msgID) as mi
-> from tbMsgContent
-> group by msgContent
-> having count(msgContent)>=2
-> ) c )
-> order by tbContent.msgID
-> limit 100;
-> until row_count()=0 end repeat;
-> delete a from tbMsgContent a inner join tbMsgContent b
-> on a.msgContent=b.msgContent and a.msgID>b.msgID;
-> end;
->
-> //
Query OK, 0 rows affected (0.01 sec)mysql>
mysql> delimiter ;
mysql> call MsgContent_pro();
Query OK, 0 rows affected (0.06 sec)mysql>怎么解决,拜谢
(
msgID bigint not null,
msgContent tinytext not null,
primary key (msgID)
);
create table tbContent
(
reID bigint not null,
msgTypeID integer not null,
isRequest boolean not null,
msgID bigint not null,
textID bigint,
fileID bigint
);delimiter //create procedure MsgContent_pro ()
begin
repeat
update tbContent
set msgID=( select mi from (select msgContent,max(msgID) as ma,min(msgID) as mi
from tbMsgContent
group by msgContent
having count(msgContent)>=2
) c where ma=tbContent.msgID)
where msgID in (select ma from (select msgContent,max(msgID) as ma,min(msgID) as mi
from tbMsgContent
group by msgContent
having count(msgContent)>=2
) c )
order by tbContent.msgID
limit 100;
until row_count()=0 end repeat;
delete a from tbMsgContent a inner join tbMsgContent b
on a.msgContent=b.msgContent and a.msgID>b.msgID;
end;//delimiter ;
msgID是唯一,但是msgContent有可能重复,所以要对msgContent去重,保留msgID最小的那项
因为表tbMsgContent中内容改变了,所以要修改tbContent中msgID项,将其改为相应的最小msgID
表tbContent中的其他项是去其他表联系的
所以涉及到该存储过程的去重问题,只是表tbMsgContent和表tbContent中的msgID项
表tbMsgContent中目前有65410659条数据
表tbContent中目前有420000条数据
where exists (select 1 from tbMsgContent where msgContent=a.msgContent)
order by msgContent,msgID;请看一下这个速度,如果可行的话,则看看用游标来解决行不行。
select * from tbMsgContent t
where exists (select 1 from tbMsgContent where msgContent=t.msgContent)
order by msgContent,msgID;
换一句试一下吧。select * from tbMsgContent where tbMsgContent='adfewr234adfa safewr' order by msgID;随便找一个有多个记录的试一下这句的执行时间。
然后再看这句的时间。select * from tbMsgContent order by msgContent desc limit 20;
select msgContent,min(msgID)
from tbMsgContent
group by msgContent
having count(*)>1
否则只能用 select * from tbMsgContent order by msgConten 做为游标来逐条判断更新了。
执行完下列代码
select msgContent,min(msgID)
from tbMsgContent
group by msgContent
having count(*)>1全部变成乱码
时间大概是1个小时45分钟
执行完下列代码 SQL codeselect msgContent,min(msgID)
from tbMsgContent
group by msgContent
having count(*)>1全部变成乱码
时间大概是1个小时45分钟
上面那个存储过程有问题啊
例如
在表tbMsgContent中有,内容重复的MsgID有1 2 3 4,也就是说得在表tbContent中修改msgID是2 3 4的项
上面的这个存储过程只是修改了msgID是4的那一项,而msgID是2 3都没有修改
怎么办?