_ 你好,
我的设置是一个慢速 SSH 到一些 linux 机器。从那里我启动一个 mysql 终端客户端并执行大约 200k 插入(在存储过程内的 while 循环中)。这大约需要 3 个小时才能完成。然而,我的内心告诉我 200k 插入不能花那么长时间(顺便说一句,数据库是空的),所以我猜测数据库的反馈(行打印到终端的标准输入文件描述符)在屏幕上打印得太慢了;首先在 linux 机器上的本地终端上,然后在我的屏幕上更慢,我正在从中进行 SSH。
我当然想关闭来自 mysqld 的所有反馈,以便只有当 mysql 的客户端提示返回时我才能知道插入何时完成。可能比 3 小时快得多。我怎么能那样做?
/etc/my.cnf 如下:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
遵循存储过程:
select 'Initializing database..';
call TigInitdb();
-- Possible encodings are:
-- - 'MD5-USERID-PASSWORD'
-- - 'MD5-PASSWORD'
-- - 'PLAIN'
-- More can be added if needed.
call TigPutDBProperty('password-encoding', 'PLAIN');
call TigPutDBProperty('schema-version', '4.0');
select 'Adding new users with PlainPw: ', '+391xxxxxx', 'pwd_xxxxxx';
drop function if exists TigUserGen;
delimiter //
create procedure TigAddUser(_user_id varchar(2049) CHARSET utf8, _user_pw varchar(255) CHARSET utf8)
begin
declare res_uid bigint unsigned;
insert into tig_users (user_id, sha1_user_id, user_pw)
values (_user_id, sha1(lower(_user_id)), _user_pw);
select LAST_INSERT_ID() into res_uid;
insert into tig_nodes (parent_nid, uid, node)
values (NULL, res_uid, 'root');
if _user_pw is NULL then
update tig_users set account_status = -1 where uid = res_uid;
end if;
select res_uid as uid;
end //
create procedure TigUserGen(usr_count INT)
begin
DECLARE cnt,len INT;
DECLARE usr CHAR(6);
SET cnt = 0;
SET len = 0;
SET usr = '';
WHILE cnt < usr_count DO
SET cnt = cnt + 1;
SET usr = CAST(cnt AS CHAR(6));
SET len = CHAR_LENGTH(usr);
CASE len
WHEN 1 THEN
call TigTestAddUser(CONCAT('+39100000', usr), CONCAT('pwd_00000', usr), 'SUCCESS - adding new user', 'ERROR - adding new user');
WHEN 2 THEN
call TigTestAddUser(CONCAT('+3910000', usr), CONCAT('pwd_0000', usr), 'SUCCESS - adding new user', 'ERROR - adding new user');
WHEN 3 THEN
call TigTestAddUser(CONCAT('+391000', usr), CONCAT('pwd_000', usr), 'SUCCESS - adding new user', 'ERROR - adding new user');
WHEN 4 THEN
call TigTestAddUser(CONCAT('+39100', usr), CONCAT('pwd_00', usr), 'SUCCESS - adding new user', 'ERROR - adding new user');
WHEN 5 THEN
call TigTestAddUser(CONCAT('+3910', usr), CONCAT('pwd_0', usr), 'SUCCESS - adding new user', 'ERROR - adding new user');
ELSE
call TigTestAddUser(CONCAT('+391', usr), CONCAT('pwd_', usr), 'SUCCESS - adding new user', 'ERROR - adding new user');
END CASE;
END WHILE;
end //
delimiter ;
call TigUserGen(200000);
谢谢
尝试注释掉 uid 的回显
尝试以 1250 为一组限制 id 的输出