2018-04-27T12:05:57.483766Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-27T12:05:57.483806Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2018-04-27T12:05:57.486165Z 0 [Warning] InnoDB: Using innodb_large_prefix is deprecated and the parameter may be removed in future>
2018-04-27T12:05:59.175629Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-04-27T12:05:59.494640Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-04-27T12:05:59.546806Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 59289cc1-4a13-11e8-9261-0050568a0453.
2018-04-27T12:05:59.579060Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-04-27T12:05:59.579540Z 1 [Note] A temporary password is generated for root@localhost: SdqwoGENy8+k
有可能会提示这样的错误
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
解决: mysql> flush privileges;
--num-threads=N number of threads to use [1] 使用最大线程 --max-requests=N limit for total number of requests [10000] 限制最大请求数
--max-time=N limit for total execution time in seconds [0] 限制最大执行时间
--forced-shutdown=STRING amount of time to wait after --max-time before forcing shutdown [off] 挂载多长时间然后根据在多长时间之后强制关闭
--thread-stack-size=SIZE > --init-rng=[on|off] initialize random number generator [off] 初始化随机数发生器 默认关闭
--test=STRING 名称
Compiled-in tests:
fileio - File I/O test IO测试
cpu - CPU performance test CPU测试
memory - Memory functions speed test 内存测试
threads - Threads subsystem performance test 线程
mutex - Mutex performance test 测试互斥性能
oltp - OLTP test 测试OLTP
Operations performed: 19577 reads, 0 writes, 0 Other = 19577 Total
Read 305.89Mb Written 0b Total transferred 305.89Mb (1.6991Mb/sec)
108.74 Requests/sec executed
General statistics:
total time: 180.0351s
total number of events: 19577
total time taken by event execution: 2878.3172
response time:
min: 5.22ms 最小
avg: 147.03ms 平均
max: 927.10ms 最大
approx. 95 percentile: 333.84ms
Threads fairness:
events (avg/stddev): 1223.5625/47.61 事件数
execution time (avg/stddev): 179.8948/0.09
[root@do3 sysbench]# sysbench --test=cpu --cpu-max-prime=20000 run
General statistics:
total time: 17.6310s
total number of events: 10000 2W个数有一万个质数?
total time taken by event execution: 17.6273
response time:
min: 1.67ms
avg: 1.76ms
max: 2.83ms
approx. 95 percentile: 1.80ms
Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 17.6273/0.00
OLTP test statistics:
queries performed:
read: 1443918 读速度
write: 0
other: 206274
total: 1650192
transactions: 103137 (1718.88 per sec.) 每秒事务 1718个
deadlocks: 0 (0.00 per sec.)
read/write requests: 1443918 (24064.32 per sec.)
other operations: 206274 (3437.76 per sec.)
General statistics:
total time: 60.0024s
total number of events: 103137
total time taken by event execution: 479.6422
response time:
min: 1.05ms
avg: 4.65ms
max: 767.15ms
approx. 95 percentile: 5.46ms
Threads fairness:
events (avg/stddev): 12892.1250/77.37
execution time (avg/stddev): 59.9553/0.00
普通索引创建
alter table table_name add index index_name
或
create index index_name on table_name
测试索引效果
创建一个库
mysql> create database test;
mysql> use test;
mysql> create table te1(id int primary key not null auto_increment,name varchar(25));
插入测试数据 、不会存储过程直接用脚本
[root@do3 tmp]# cat tests.sh
#!/bin/bash
#
MYSQL_USER=root
MYSQL_PASSWD=xiong123
echo `date`
for i in {1..50000};do
user=`cat /dev/urandom | head -5 | md5sum | head -c 5`
mysql -u${MYSQL_USER} -p${MYSQL_PASSWD} -h "192.168.9.224" -e "insert into test.te1 values (${i},'${user}')" &>/dev/null
done
echo `date`
echo "done"
5万条数据整了8分钟,像测试最好用存储过程
无索引查询
mysql> select * from te1 ;
查看索引
key:null表示没有索引 合理添加索引三个 "经常"
1) 经常被查询的列 ( 一般放在where后面)
2) 经常用于表连接的列
3) 经常排序分组的列(order by 或者group by 后面的字段)
越靠近1说明索引效果越好