Professional Documents
Culture Documents
2010DBA
2012RDS
RDS
RDS11
RDS
hidba.org
SQL
conn 100%
cpu 100%
iops 100%
disk 100%
mem 100%
CPU 100%
sql2S
SQLSELECT uid FROM `user` WHERE mo=13772556391 LIMIT 0,1;
mysql> explain SELECT uid FROM `user` WHERE mo=13772556391 LIMIT 0,1;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: user
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 707250
Extra: Using where
mysql> explain SELECT uid FROM `user` WHERE mo=13772556391 LIMIT 0,1\G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: user
type: index
possible_keys: ind_mo
key: ind_mo
key_len: 33
ref: NULL
rows: 707250
Extra: Using where; Using index
mysql> explain extended select uid from`user` where mo=13772556391 limit 0,1;
mysql> show warnings;
Warning1Cannot use index 'ind_mo' due to type or collation conversion on field 'mo'
Noteselect `user`.`uid` AS `uid` from `user` where (`user`.`mo` = 13772556391) limit 0,1
CREATE TABLE `user` (
`mo` char(11) NOT NULL DEFAULT '' ,
) ENGINE=InnoDB;
mysql> explain SELECT uid FROM `user` WHERE mo='13772556391' LIMIT 0,1\G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: user
type: ref
possible_keys: ind_mo
key: ind_mo
key_len: 33
ref: const
rows: 1
Extra: Using where; Using index
3
,:date(a.gmt_create)
SQL
4
sql
SQL
tselleridid
create index ind_sellerid on buyer(sellerid);
select t2.*
from (select id
from buyer where sellerId = 765922982
and gmt_modified >= '1970-01-01 08:00:00'
and gmt_modified <= '2013-06-05 17:11:31'
limit 255000, 5000t1,
buyer t2
where t1.id=t2.id
60S0.2S
SELECT first_name
FROM employees
WHERE emp_no IN
(SELECT emp_no FROM salaries_2000 WHERE salary = 5000);
MySQLemployees
SELECT first_name
FROM employees emp,
(SELECT emp_no FROM salaries_2000 WHERE salary = 5000) sal
WHERE emp.emp_no = sal.emp_no;
1200S0.1S
SQL
1
Limit
2
5.15.5
Mysql 5.6
3
SELECT *
InnodbMyisam
CREATE TABLE `t_myisam` (
`id` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
TipsDDL
1 1.myisaminnodb
2.
3.MySQL5.6online ddl
2 1.
2.SQL
3.lock wait
4.ApsaraDBDDL wait timeout
| 5.6
5
MySQL
DDL
DDLcreate indexrepairoptimze tablealter table add column
Tips
show processlist
Tips
+
CPU+IOPS
1 1.
2.
3.
2 1.innodb
2.
3.
4.DDL
rds1
RDS1
1 PG->MySQLORALCE->MySQL
2 (MySQL:5.1->5.55.5->5.6)
5.6RDS5.6
OPTIMIZER_SWITCH:
index_merge=on,index_merge_union=on,index_merge_sort_union=on,
index_merge_intersection=on,engine_condition_pushdown=on,
index_condition_pushdown=on,mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,materialization=on,
semijoin=on,loosescan=on,firstmatch=on,
subquery_materialization_cost_based=on,use_index_extensions=on
SQLrows=39900*1*1*140*285*1*1*1*1*1*1*1
join_buffer_size = 128M
read_rnd_buffer_size = 128M
tmp_table_size = 128M
RDS
join_buffer_size = 1M
read_buffer_size = 1M
tmp_table_size =256K
tmp_table_size256K128MB
1 1.SQL
2.
3.
4.
2 1.Query_cache_size
2.Temp_table_size
3.Tokudb_buffer_pool_ratio
4.Back_log
cpu 100%
cpu 100%
SQL
Cpu 100%
SQL
1 1.
2 1.
3 1.
conn 100%
conn 100%
SQL
Conn 100%
SQL
1 1.
2 1.
3 1.
2.RDS
iops 100%
Iops 100%
SQL
1 1.
DDL
2 1. create indexoptimze tablealter table add column
3 1.RDS
disk 100%
disk 100%
1 1.optimize table
2.tokudb
2 1.
2.truncate delete from
3 1.sort_buffer_size
2.
mem 100%
mem 100%
Buffer pool size Dictionary memoryThread cost memory
Buffer pool size
1 1.
2.
Dictionary memory
3 1.
Thank you !