cocos

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  24 随笔 :: 0 文章 :: 0 评论 :: 0 引用

2011年5月6日 #

DELIMITER $$
USE `servant_591up`$$
DROP PROCEDURE IF EXISTS `sp_move_data`$$
CREATE  PROCEDURE `sp_move_data`()
BEGIN
DECLARE v_exit INT DEFAULT 0;
DECLARE v_spid BIGINT;
DECLARE v_id BIGINT;
DECLARE i INT DEFAULT 0;
DECLARE c_table INT;
DECLARE v_UniqueKey VARCHAR(57);
DECLARE v_TagCatalogId INT;
DECLARE v_RootCatalogId INT;
DECLARE v_UserId BIGINT;
DECLARE v_QuestionId CHAR(36);
DECLARE v_CorrectCount  INT;
DECLARE v_ErrorCount INT;
DECLARE v_LastIsCorrect INT;
DECLARE v_LastAnswerXML TEXT CHARSET utf8;
DECLARE v_TotalCostTime INT;
DECLARE v_Reviews VARCHAR(200) CHARSET utf8;
DECLARE v_AnswerResultCategory INT;
DECLARE v_LastCostTime INT;
DECLARE v_LastAnswerTime DATETIME;
DECLARE v_IsPublic INT;
DECLARE v_SUBJECT INT;
DECLARE v_TotalCount INT;
DECLARE v_AnswerMode SMALLINT(6);
DECLARE v_ExerciseWeight FLOAT;
DECLARE c_ids CURSOR FOR SELECT UniqueKey,TagCatalogId,RootCatalogId,UserId,QuestionId,CorrectCount,ErrorCount,LastIsCorrect,LastAnswerXML,TotalCostTime,Reviews,AnswerResultCategory,LastCostTime,LastAnswerTime,IsPublic,SUBJECT,TotalCount,AnswerMode,ExerciseWeight FROM ol_answerresult_56;
DECLARE  CONTINUE HANDLER FOR NOT FOUND SET v_exit=1;
OPEN c_ids;
REPEAT
FETCH c_ids INTO v_UniqueKey,v_TagCatalogId,v_RootCatalogId,v_UserId,v_QuestionId,v_CorrectCount,v_ErrorCount,v_LastIsCorrect,v_LastAnswerXML,v_TotalCostTime,v_Reviews,v_AnswerResultCategory,v_LastCostTime,v_LastAnswerTime,v_IsPublic,v_SUBJECT,v_TotalCount,v_AnswerMode,v_ExerciseWeight;
IF v_exit = 0 THEN
SET @vv_id = v_id;
SELECT MOD(v_UserId,100) INTO c_table;
SET @SQL_CONTEXT =
CONCAT('INSERT INTO new_answerresult_',
c_table,'
(UniqueKey,TagCatalogId,RootCatalogId,UserId,QuestionId,CorrectCount,ErrorCount,LastIsCorrect,LastAnswerXML,TotalCostTime,Reviews,AnswerResultCategory,LastCostTime,LastAnswerTime,IsPublic,SUBJECT,TotalCount,AnswerMode,ExerciseWeight)values(',
'''',v_UniqueKey,'''',',',
v_TagCatalogId,',',
v_RootCatalogId,',',
v_UserId,',',
'''',v_QuestionId,'''',',',
v_CorrectCount,',',
v_ErrorCount,',',
v_LastIsCorrect,',',
'''',v_LastAnswerXML,'''',',',
v_TotalCostTime,',',
'''',REPLACE(IFNULL(v_Reviews,''),'''',''),'''',',',
v_AnswerResultCategory,',',
v_LastCostTime,',',
'''',v_LastAnswerTime,'''',',',
v_IsPublic,',',
v_SUBJECT,',',
v_TotalCount,',',
v_AnswerMode,',',
v_ExerciseWeight,')');
PREPARE STMT FROM @SQL_CONTEXT;
EXECUTE STMT ;
DEALLOCATE PREPARE STMT;
END IF;
SET i=i+1;
#100
#IF MOD(i,100)=0 THEN COMMIT;
#END IF;
UNTIL v_exit=1
END REPEAT;
CLOSE c_ids;
#COMMIT;
END$$
DELIMITER ;
posted @ 2011-05-06 22:53 大柳树 阅读(54) 评论(0) 编辑

LOAD DATA LOCAL INFILE 'c:\userlist.txt' INTO TABLE temp_user
FIELDS ESCAPED BY '\\' TERMINATED BY '\t' LINES TERMINATED BY '\r\n' (`username`, `userid`)
CREATE TABLE tc_userinfo(`username` VARCHAR(100),`ip` VARCHAR(100))
ENGINE = MYISAM DEFAULT CHARSET=utf8
SELECT * FROM tc_userinfo
ORDER BY papertimes DESC
1.关联userid
UPDATE tc_userinfo t ,ol_user u SET t.userid = u.userid WHERE t.username = u.username
/*truncate table ol_ip_tongchao*/
SELECT INET_ATON('123.15.57.50')
SELECT * FROM ol_ip_tongchao WHERE startip<2064595250 AND endip>2064595250
2.ip数据
LOAD DATA LOCAL INFILE 'c:\ip01.txt' INTO TABLE `servant_591up`.`ol_ip_tongchao`
FIELDS ESCAPED BY '\\' TERMINATED BY ',' LINES TERMINATED BY '\r\n' (`startip`, `endip`, `pos`,`detail`)
SELECT COUNT(*) FROM ol_ip_tongchao
TRUNCATE TABLE ol_ip_tongchao
SELECT * FROM ol_ip_tongchao LIMIT 100
SELECT INET_ATON('114.229.74.103')
UPDATE tc_userinfo t ,ol_ip_tongchao i SET t.diqu = i.pos WHERE INET_ATON(t.ip)>=i.startip AND INET_ATON(t.ip)<=i.endip
SELECT * FROM ol_ip_tongchao WHERE INET_ATON('114.229.74.103')
>startip AND INET_ATON('114.229.74.103')< endip
3.
UPDATE tc_userinfo t SET t.racetimes = 
(SELECT COUNT(*) FROM gwy_raceresult WHERE userid = t.userid)
4.
UPDATE tc_userinfo t SET t.papertimes = 
(SELECT COUNT(*) FROM ol_simulatelog WHERE userid = t.userid)
5.
UPDATE tc_userinfo t SET t.questiontimes = 
(SELECT COUNT(*) FROM ol_answerlog WHERE userid = t.userid)
6.
EXPLAIN
UPDATE tc_userinfo t SET t.wrongtimes = 
(SELECT COUNT(*) FROM ol_answerlog_tmp WHERE userid = t.userid AND IsCorrect = 0)
UPDATE tc_userinfo t , ol_answerlog l SET t.wrongtimes = 1
WHERE t.userid = l.userid AND l.IsCorrect = 0
CREATE TABLE ol_answerlog_tmp
SELECT * FROM ol_answerlog WHERE userid IN(SELECT userid FROM tc_userinfo)
7.
UPDATE tc_userinfo t SET t.rewrongtimes = ( SELECT 
COUNT(*)  FROM ol_tc_wrong WHERE userid = t.userid )
9.
UPDATE tc_userinfo t SET t.reviews = ( SELECT 
COUNT(*)  FROM ol_userreviews WHERE userid = t.userid AND Reviews IS NOT NULL AND Reviews<>'' )
SELECT * FROM ol_userreviews  WHERE Reviews IS NOT NULL AND Reviews<>''LIMIT 100 
posted @ 2011-05-06 22:52 大柳树 阅读(16) 评论(0) 编辑

摘要: mysql函数大全 对于针对字符串位置的操作,第一个位置被标记为1。 ASCII(str) 返回字符串str的最左面字符的ASCII代码值。如果str是空字符串,返回0。如果str是NULL,返回NULL。 mysql> select ASCII('2'); -> 50 mysql> select ASCII(2); -> 50 mysql> select ASCII('dx'); -> 100 也可参见ORD()函数。 ORD(str) 如果字符串str最左面字符是一个多字节字符,通过以格式((first byte ASCI阅读全文
posted @ 2011-05-06 22:50 大柳树 阅读(143) 评论(0) 编辑

mysql_upgrade should be executed each time you upgrade MySQL. It checks all tables in all databases for incompatibilities with the current version of MySQL Server. If a table is found to have a possible incompatibility, it is checked. If any problems are found, the table is repaired. mysql_upgrade also upgrades the system tables so that you can take advantage of new privileges or capabilities that might have been added.
All checked and repaired tables are marked with the current MySQL version number. This ensures that next time you run mysql_upgrade with the same version of the server, it can tell whether there is any need to check or repair the table again.
mysql_upgrade also saves the MySQL version number in a file named mysql_upgrade.info in the data directory. This is used to quickly check if all tables have been checked for this release so that table-checking can be skipped.
To check and repair tables and to upgrade the system tables, mysql_upgrade executes the following commands:
mysqlcheck --check-upgrade --all-databases --auto-repair mysql_fix_privilege_tables
mysql_upgrade currently works only on Unix.
To use mysql_upgrade, make sure that the server is running, and then invoke it like this:
shell> mysql_upgrade 
posted @ 2011-05-06 22:38 大柳树 阅读(30) 评论(0) 编辑

EXPLAIN 
SELECT COUNT(*) FROM ol_answerresult_1 INNER JOIN ol_question ON ol_answerresult_1.QuestionId = ol_question.QuestionId   AND PaperId='00000000-0000-0000-0000-000000000000' AND ol_question.IsConfirmed=1 AND QuestionCategory=1  AND ol_question.SimilarType<>2 AND (GKYear!=0 OR GKArea!=0) WHERE ol_answerresult_1.userid=39176 AND ol_answerresult_1.SUBJECT=10
EXPLAIN
SELECT SQL_NO_CACHE questionid,AllTagCatalogId 
FROM ol_question WHERE MATCH(AllTagCatalogId)AGAINST (7117,7116);
EXPLAIN
MATCH() AGAINST
SELECT SQL_NO_CACHE questionid
FROM ol_question WHERE AllTagCatalogId LIKE '%7116%';
SELECT BENCHMARK(1000000,(SELECT SQL_NO_CACHE questionid FROM ol_question WHERE MATCH(AllTagCatalogId)AGAINST ('7116') LIMIT 1))
SELECT BENCHMARK(1000000,(SELECT SQL_NO_CACHE questionid FROM ol_question WHERE AllTagCatalogId LIKE '%7116%' LIMIT 1))
SELECT BENCHMARK(10000000,CURRENT_DATE())
posted @ 2011-05-06 22:37 大柳树 阅读(12) 评论(0) 编辑

mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=200 --iterations=1 --number-int-cols=4 --auto-generate-sql --auto-generate-sql-load-type=mixed,update,write,key,read --engine=myisam --number-of-queries=1000 -uroot -p8319999
mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=200 --iterations=10 --number-int-cols=4 --auto-generate-sql --auto-generate-sql-load-type=update --engine=myisam --number-of-queries=10000 -uroot -p8319999
mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=100 --iterations=10 --number-int-cols=4 --auto-generate-sql --auto-generate-sql-load-type=write --engine=myisam,innodb --number-of-queries=5000 -uroot -p8319999
mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=100 --iterations=10 --number-int-cols=4 --auto-generate-sql-guid-primary --auto-generate-sql --auto-generate-sql-load-type=write --engine=myisam --number-of-queries=5000 -uroot -p8319999
mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=10 --iterations=10  --auto-generate-sql-guid-primary --auto-generate-sql --auto-generate-sql-load-type=write --engine=myisam --number-of-queries=50 -uroot -p8319999
mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=200 --iterations=1 --number-int-cols=4 --auto-generate-sql --auto-generate-sql-load-type=mixed,update,write,key,read --engine=myisam --number-of-queries=10000 -uroot -p8319999
mysqlslap  --concurrency=50 --iterations=1 --create-schema=gwy_591up_237 --query="INSERT INTO ol_answerresult_test (UniqueKey, TagCatalogId, RootCatalogId, UserId, QuestionId, CorrectCount, ErrorCount, LastIsCorrect, LastAnswerXML, TotalCostTime, Reviews, AnswerResultCategory, LastCostTime, LastAnswerTime, IsPublic, SUBJECT, TotalCount, AnswerMode, ExerciseWeight ) VALUES ( '3313_67bd0665-3d82-4622-9bf0-c4bb36fd2cd6', 7122, '7115', 3313, '67bd0665-3d82-4622-9bf0-c4bb36fd2cd6', '1', '1', '0', '<as><a><i><![CDATA[B]]></i></a></as>', '25', '', '1', '25', '2011-04-21 21:18:49', '1', '10', '1', '0', '0' )" --number-of-queries=10000 -uroot -h192.168.56.221 -p888888
mysqlslap  --concurrency=1 --iterations=10 --create-schema=gwy_591up_237 --query="INSERT INTO ol_answerresult_test (UniqueKey, TagCatalogId,RootCatalogId,UserId,QuestionId,CorrectCount,ErrorCount, LastIsCorrect,LastAnswerXML,TotalCostTime,Reviews, AnswerResultCategory, LastCostTime, LastAnswerTime,IsPublic,SUBJECT,TotalCount,AnswerMode,ExerciseWeight)VALUES('3313_67bd0665-3d82-4622-9bf0-c4bb36fd2cd6', 7122, '7115', 3313, '67bd0665-3d82-4622-9bf0-c4bb36fd2cd6','1','1','0','<as><a><i><![CDATA[B]]></i></a></as>','25','','1','25','2011-04-21 21:18:49','1','10','1','0','0')" --number-of-queries=10000 -uspace -h192.168.56.221 -p888888
mysqlslap  --concurrency=10 --iterations=1 --create-schema=tongchao --query="INSERT INTO ol_answerresult_test (UniqueKey, TagCatalogId,RootCatalogId,UserId,QuestionId,CorrectCount,ErrorCount, LastIsCorrect,LastAnswerXML,TotalCostTime,Reviews, AnswerResultCategory, LastCostTime, LastAnswerTime,IsPublic,SUBJECT,TotalCount,AnswerMode,ExerciseWeight)VALUES('3313_67bd0665-3d82-4622-9bf0-c4bb36fd2cd6', 7122, '7115', 3313, '67bd0665-3d82-4622-9bf0-c4bb36fd2cd6','1','1','0','<as><a><i><![CDATA[B]]></i></a></as>','25','','1','25','2011-04-21 21:18:49','1','10','1','0','0')" --number-of-queries=10000 -uspace -h192.168.56.221 -p888888 -P3307
posted @ 2011-05-06 22:33 大柳树 阅读(92) 评论(0) 编辑

C:\Program Files\MySQL\MySQL Server 5.1\scripts>mysqlslap --defaults-file="C:/Pr
ogram Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=50 --iterations=1 --num
ber-int-cols=4 --auto-generate-sql --auto-generate-sql-load-type=update --engine
=myisam --number-of-queries=10000 -uroot -p8319999
update
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 16.187 seconds
        Minimum number of seconds to run all queries: 16.187 seconds
        Maximum number of seconds to run all queries: 16.187 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
read
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 5.703 seconds
        Minimum number of seconds to run all queries: 5.703 seconds
        Maximum number of seconds to run all queries: 5.703 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
write
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 1.765 seconds
        Minimum number of seconds to run all queries: 1.765 seconds
        Maximum number of seconds to run all queries: 1.765 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 7.968 seconds
        Minimum number of seconds to run all queries: 7.968 seconds
        Maximum number of seconds to run all queries: 7.968 seconds
        Number of clients running queries: 50
        Average number of queries per client: 1000
mixed:
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 52.281 seconds
        Minimum number of seconds to run all queries: 52.281 seconds
        Maximum number of seconds to run all queries: 52.281 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 51.985 seconds
        Minimum number of seconds to run all queries: 51.985 seconds
        Maximum number of seconds to run all queries: 51.985 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
C:\Program Files\MySQL\MySQL Server 5.1\scripts>mysqlslap --defaults-file="C:/Pr
ogram Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=50 --iterations=1 --cre
ate-schema=edu_591up --query="select userid from ol_user where username='zbwangc
hao@163.com'" --number-of-queries=10000 -uroot -p8319999
Benchmark
        Average number of seconds to run all queries: 3.813 seconds
        Minimum number of seconds to run all queries: 3.813 seconds
        Maximum number of seconds to run all queries: 3.813 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
C:\Program Files\MySQL\MySQL Server 5.1\scripts>mysqlslap --defaults-file="C:/Pr
ogram Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=50 --iterations=10 --cr
eate-schema=edu_591up --query="select userid,username from ol_user where userid=
25091" --number-of-queries=10000 -uroot -p8319999
Benchmark
        Average number of seconds to run all queries: 1.746 seconds
        Minimum number of seconds to run all queries: 0.781 seconds
        Maximum number of seconds to run all queries: 1.954 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
C:\Program Files\MySQL\MySQL Server 5.1\scripts>mysqlslap --defaults-file="C:/Pr
ogram Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=50 --iterations=10 --cr
eate-schema=edu_591up --query="update ol_user set username='zbwangchao@163.com'
where userid=25091" --number-of-queries=10000 -uroot -p8319999
Benchmark
        Average number of seconds to run all queries: 2.229 seconds
        Minimum number of seconds to run all queries: 1.969 seconds
        Maximum number of seconds to run all queries: 3.172 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
C:\Program Files\MySQL\MySQL Server 5.1\scripts>mysqlslap --defaults-file="C:/Pr
ogram Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=50 --iterations=10 --cr
eate-schema=edu_591up --query="insert into ol_user(username,password)values('ton
gchao','dddddddddddddddd')" --number-of-queries=10000 -uroot -p8319999
Benchmark
        Average number of seconds to run all queries: 8.992 seconds
        Minimum number of seconds to run all queries: 8.078 seconds
        Maximum number of seconds to run all queries: 9.750 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
C:\Program Files\MySQL\MySQL Server 5.1\scripts>mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=50 --iterations=1 --create-schema=edu_591up --query="insert into ol_user(username,password)values('tongchao','dddddddddddddddd')" --number-of-queries=10000 -uroot -p8319999
Benchmark
        Average number of seconds to run all queries: 2.000 seconds
        Minimum number of seconds to run all queries: 2.000 seconds
        Maximum number of seconds to run all queries: 2.000 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
(无索引)
mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=50 --iterations=1 --create-schema=edu_591up --query="insert into ol_user(username,password)values('tongchao','dddddddddddddddd')" --number-of-queries=10000 -uroot -p8319999
mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=50 --iterations=1 --create-schema=edu_591up --query="update ol_user set password='tongchaotongchao' where userid = 13" --number-of-queries=10000 -uroot -p8319999
mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=50 --iterations=1 --create-schema=edu_591up --query="select * from ol_user where userid = 13" --number-of-queries=10000 -uroot -p8319999
*******************************************************************************************************************************
mysqlslap --defaults-file="D:/MySQL/MySql5.5/my.ini" --concurrency=50 --iterations=1 --create-schema=edu_591up --query="insert into ol_user(username,password)values('tongchao','dddddddddddddddd')" --number-of-queries=10000 -uroot
mysqlslap --defaults-file="D:/MySQL/MySql5.5/my.ini" --concurrency=50 --iterations=1 --create-schema=edu_591up --query="update ol_user set password='tongchaotongchao' where userid = 13" --number-of-queries=100000 -uroot
mysqlslap --defaults-file="D:/MySQL/MySql5.5/my.ini" --concurrency=50 --iterations=1 --create-schema=edu_591up --query="select * from ol_user where userid = 13" --number-of-queries=10000 -uroot
二、自动测试
mysqlslap --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --concurrency=50 --iterations=1 --number-int-cols=4 --auto-generate-sql --auto-generate-sql-load-type=update --engine=myisam,innodb --number-of-queries=10000 -uroot -p8319999
mysqlslap --defaults-file="D:/MySQL/MySql5.5/my.ini" --concurrency=50 --iterations=1 --number-int-cols=4 --auto-generate-sql --auto-generate-sql-load-type=update --engine=myisam,innodb --number-of-queries=10000 -uroot
mysqlslap --defaults-file="C:/Program Files/MySQL/mysql-5.1.54-win32/my.ini" --concurrency=50 --iterations=1 --number-int-cols=4 --auto-generate-sql --auto-generate-sql-load-type=update --engine=myisam,innodb --number-of-queries=10000 -uroot
结果:
5.1
update:
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 17.547 seconds
        Minimum number of seconds to run all queries: 17.547 seconds
        Maximum number of seconds to run all queries: 17.547 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 47.860 seconds
        Minimum number of seconds to run all queries: 47.860 seconds
        Maximum number of seconds to run all queries: 47.860 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
write:
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 1.587 seconds
        Minimum number of seconds to run all queries: 0.766 seconds
        Maximum number of seconds to run all queries: 1.890 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 1.868 seconds
        Minimum number of seconds to run all queries: 1.812 seconds
        Maximum number of seconds to run all queries: 2.094 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
mixed:
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 52.453 seconds
        Minimum number of seconds to run all queries: 52.453 seconds
        Maximum number of seconds to run all queries: 52.453 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 66.531 seconds
        Minimum number of seconds to run all queries: 66.531 seconds
        Maximum number of seconds to run all queries: 66.531 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
5.5
update:
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 14.360 seconds
        Minimum number of seconds to run all queries: 14.360 seconds
        Maximum number of seconds to run all queries: 14.360 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 43.843 seconds
        Minimum number of seconds to run all queries: 43.843 seconds
        Maximum number of seconds to run all queries: 43.843 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
        
write:
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 1.526 seconds
        Minimum number of seconds to run all queries: 0.703 seconds
        Maximum number of seconds to run all queries: 1.766 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 1.573 seconds
        Minimum number of seconds to run all queries: 0.766 seconds
        Maximum number of seconds to run all queries: 1.828 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
mixed:
Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 39.468 seconds
        Minimum number of seconds to run all queries: 39.468 seconds
        Maximum number of seconds to run all queries: 39.468 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 50.468 seconds
        Minimum number of seconds to run all queries: 50.468 seconds
        Maximum number of seconds to run all queries: 50.468 seconds
        Number of clients running queries: 50
        Average number of queries per client: 200
C:\Documents and Settings\Administrator>mysqlslap --defaults-file="D:/MySQL/MySq
l5.5/my.ini" --concurrency=100 --iterations=5 --number-int-cols=4 --auto-generat
e-sql --auto-generate-sql-load-type=update --engine=innodb --number-of-queries=1
000 -uroot
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 3.371 seconds
        Minimum number of seconds to run all queries: 2.547 seconds
        Maximum number of seconds to run all queries: 4.515 seconds
        Number of clients running queries: 100
        Average number of queries per client: 10
        
        
 C:\Documents and Settings\Administrator>mysqlslap --defaults-file="C:/Program
les/MySQL/mysql-5.1.54-win32/my.ini" --concurrency=100 --iterations=5 --number
nt-cols=4 --auto-generate-sql --auto-generate-sql-load-type=update --engine=in
db --number-of-queries=1000 -uroot
Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 3.831 seconds
        Minimum number of seconds to run all queries: 3.797 seconds
        Maximum number of seconds to run all queries: 3.860 seconds
        Number of clients running queries: 100
        Average number of queries per client: 10       
posted @ 2011-05-06 22:33 大柳树 阅读(188) 评论(0) 编辑

mysqlbinlog -R -h 192.168.56.221 -u tongchao -p111111 mysql0-bin.000001 --start-datetime="2010-12-22 00:00:00" --stop-datetime="2010-12-22 05:00:00"
远程binlog获取
需要权限,
replication slave权限

 

mysqlbinlog -d 591up /data0/mysql/3306/tc/log-bin.000536 --start-datetime='2010-12-20 00:02:50' | grep ol_question >/data0/mysql/ol_question2.txt
 mysqlbinlog -d 591up /data0/mysql/3306/tc/log-bin.000536 --start-datetime='2010-12-20 00:02:50' | grep ol_question >/data0/mysql/ol_question2.txt
mysqlbinlog -d servant_591up "D:/3.7/logbin/log-bin.000456" --start-datetime="2011-03-04 21:00:00"  --stop-datetime="2011-03-04 22:10:00" >d:/sql/2011race/binlog.sql
mysqlbinlog -d servant_591up D:\sql\0415race\log-bin.000545 >> D:\sql\0415race\servant_591up.sql
mysqlbinlog -d servant_591up D:\sql\0415race\log-bin.000546 >> D:\sql\0415race\servant_591up.sql
mysqlbinlog -d servant_591up D:\sql\0415race\log-bin.000547 >> D:\sql\0415race\servant_591up.sql
mysqlbinlog -d servant_591up D:\sql\0415race\log-bin.000548 >> D:\sql\0415race\servant_591up.sql
mysqlsla.pl -lt binary "D:\sql\0415race\servant_591up.sql" > D:\sql\0415race\mysqlsla.txt --top 100
mysqlsla.pl --log-type slow "D:/861028/slow_query.log" >d:/sql/slow.txt

mysqlsla.pl -lt slow "D:/_861028/slow_query.log" -R print-unique -mf "db=591up" -sf "+SELECT"  

 

posted @ 2011-05-06 22:32 大柳树 阅读(99) 评论(0) 编辑

MySQL与MSSQL 有一个区别在于MySQL建表的时候需要选择存储引擎,常用的存储引擎有MyISAM和InnoDB
而由于InnoDB是一个健壮的事务型存储引擎,已经有10多年的历史,一些重量级的互联网公司(Yahoo,Google Netease ,Taobao)也经常使用
我的日常工作也经常接触InnoDB,现在就InnoDB一部分可以改善性能的参数列举
1. innodb_additional_mem_pool_size 
除了缓存表数据和索引外,可以为操作所需的其他内部项分配缓存来提升InnoDB的性能。这些内存就可以通过此参数来分配。推荐此参数至少设置为2MB,实际上,是需要根据项目的InnoDB表的数目相应地增加
2.innodb_data_pool_size
此参数类似于MySQL的key_buffer参数,但特定用于InnoDB表.这个参数确定了要预留多少内存来缓存表数据和索引。与key_buffer一样,更高的设置会提升性能,可以是服务器的内存70-80%
3.innodb_data_file_path
参数的名字和实际的用途有点出入,它不仅指定了所有InnoDB数据文件的路径,还指定了初始大小分配,最大分配以及超出起始分配界线时是否应当增加文件的大小。此参数的一般格式如下:
path-to-datafile:size-allocation[:autoextend[:max-size-allocation]]
例如,假设希望创建一个数据文件sales,初始大小为100MB,并希望在每次达到当前大小限制时,自动增加8MB(8MB是指定autoextend时的默认扩展大小).但是,不希望此文件超过1GB,可以使用如下配置:
innodb_data_home_dir = 
innodb_data_file_path = /data/sales:100M:autoextend:8M: max:1GB
如果此文件增加到预定的1G的限制,可以再增加另外一个数据文件,如下:
innodb_data_file_path = /data/sales:100M:autoextend:8M: max:1GB;innodb_data_file_path = /data2/sales2:100M:autoextend:8M: max:2GB
要注意的是,在这些示例中,inndb_data_home_dir参数开始设置为空,因为最终数据文件位于单独的位置(/data/和/data2/).如果希望所有 InnoDB数据文件都位于相同的位置,就可以使用innodb_data_home_dir来指定共同位置,然后在通过 inndo_data_file_path来指定文件名即可。如果没有定义这些值,将在datadir中创建一个sales。
4 innodb_data_home_dir
此参数指定创建InnoDB表空间的路径的公共部分,默认情况下,这是MySQL的默认数据,由MySQL参数datadir指定
5. innodb_file_io_threads
此参数指定InnoDB表可用的文件I/O线程数,MySQL开发人员建议在非Windows平台中这个参数设置为4
6. innodb_flush_log_at_trx_commit
如果将此参数设置为1,将在每次提交事务后将日志写入磁盘。为提供性能,可以设置为0或2,但要承担在发生故障时丢失数据的风险。设置为0表示事务日志写入日志文件,而日志文件每秒刷新到磁盘一次。设置为2表示事务日志将在提交时写入日志,但日志文件每次刷新到磁盘一次。
7.innodb_log_archive
因为MySQL目前使用自己的日志文件恢复InnoDB表,此参数可设置为0
8.innodb_log_arch_dir
MySQL目前忽略此参数,但会在未来的版本中使用。目前,应当将其设置为与innodb_log_group_home_dir相同的值
9.innodb_log_buffer_size
此参数确定些日志文件所用的内存大小,以M为单位。缓冲区更大能提高性能,但意外的故障将会丢失数据.MySQL开发人员建议设置为1-8M之间
10. innodb_log_file_size
此参数确定数据日志文件的大小,以M为单位,更大的设置可以提高性能,但也会增加恢复故障数据库所需的时间
11.innodb_log_files_in_group
为提高性能,MySQL可以以循环方式将日志文件写到多个文件。推荐设置为3M
12. innodb_log_group_home_dir
此参数确定日志文件组中的文件的位置,日志组中文件的个数由innodb_log_files_in_group确定,此位置设置默认为MySQL的datadir
13.innodb_lock_wait_timeout
InnoDB 有其内置的死锁检测机制,能导致未完成的事务回滚。但是,如果结合InnoDB使用MyISAM的lock tables 语句或第三方事务引擎,则InnoDB无法识别死锁。为消除这种可能性,可以将innodb_lock_wait_timeout设置为一个整数值,指示 MySQL在允许其他事务修改那些最终受事务回滚的数据之前要等待多长时间(秒数)
14.skip-innodb
启用此参数能防止夹杂InnoDB表驱动程序,不使用InnoDB表时推荐此设置
posted @ 2011-05-06 22:21 大柳树 阅读(64) 评论(0) 编辑

SET @rowNum = 0;
SELECT userid,@rowNum:=@rowNum+1 AS rowNo FROM ol_user ORDER BY userid DESC LIMIT 10;
posted @ 2011-05-06 22:19 大柳树 阅读(15) 评论(0) 编辑