mysql order group

##order by排序的字段若有重复则创建索引时可以加一个唯一索引的字段创建索引  alter table employee add index ind_birth_empno(birth,emp_no)

##分页优化 若limit(limit 10000000,20表示从一千万中取前20条)比较大时后面的分页比较慢  优化创建索引:1、alter table employee add index ind_birth_empno(birth,emp_no) 2、 select * from employee order by birth_date,emp_no limit 30; 3、select * from employee where (birth,emp_no)>('1987-02-03',456258) order by birth_date,emp_no limit 30; ##where条件是从上一页数据中最后一条的数据

s how variables like 'sort_buffer_%';  

show variables like 'tmp_%';

###sort_merge_passes比较大时需要增加sort_buffer_size大小

 

 ###created_tmp_disk_tables比较大时需要增加tmp_table_size大小

 

 

 ##group concat()函数

 

 

 

posted @ 2022-06-13 17:45  howhy  阅读(131)  评论(0编辑  收藏  举报