索引的设计:

1. 索引的设计应根据实际的统计需求而定,主要体现在order by, group by的需求上

2. 过多的需求不应导致过多的索引: key base1(...),key base2(...),... 过多的索引会导致insert,update相当费时

3. 索引的字段应该为各类order by, group by的字段的公共前缀,而不是过多的索引。如 group by a,b,c,d;group by a,b,c,e 则索引应该为key base(a,b,c). 而不是创建两个索引 key base1(a,b,c,d),key base2(a,b,c,e)

4. 用desc/explain可能发现有:Using where; Using temporary; Using filesort . 此时可能考虑要优化。当然数据两过大,group by的字段不应设为索引也无法避免 Using temporary。但合理地设计索引同样会提高 Using temporary的效率

5. 索引的设计应该精简合理,不混乱错综

6. mysql的核心在于索引

 

数据的插入:

1. mysqlimport 实际调用了load data...  其效率比insert高。所以数据入库应该使用mysqlimport 而不是逐条insert

2. 如有可能,使用awk脚本将文件分块确实方便

 

其他:

1. 每天应该总结,思考,学习

2. 别拘于工作,应该拓展

 

相关文章:

  • 2021-12-30
  • 2021-08-20
  • 2022-12-23
  • 2021-08-27
  • 2022-01-30
  • 2022-12-23
  • 2021-05-11
  • 2021-06-23
猜你喜欢
  • 2021-11-16
  • 2021-06-06
  • 2022-12-23
  • 2021-05-19
  • 2022-02-12
  • 2022-01-29
  • 2021-06-18
相关资源
相似解决方案