一次要读出几十万条数据,MYSQL该如何修改配置文件?
定时统计数据,一次要读出几十万的数据,请问my.cnf该如何配置?
服务器500G硬盘,8G内存,1颗4核CPU
下面是我的配置
11 local-infile=0
12 #set-variable = local-infile=0 (exactly the same as the prior line but the old syntax way of doing it)
13 #skip-locking (default is skip-external-locking as the name is no longer skip-locking and skip-external-locking is the default)
14 max_connections = 120
15 key_buffer_size = 1024M
16 long_query_time = 1
17 log-slow-queries = /home/log/mysql_slow_log.txt
18 open_files_limit= 500000
19 max_allowed_packet = 4M
20 #table_cache = 512
21 table_cache = 20M
22 #sort_buffer_size = 2M
23 #read_buffer_size = 2M
24 sort_buffer_size = 50M
25 read_buffer_size = 50M
26 read_rnd_buffer_size = 50M
27 myisam_sort_buffer_size = 256M
28 thread_cache_size = 64
29 #query_cache_size = 32M
30 query_cache_size = 128M
31 query_cache_limit = 128M
32 #thread_concurrency = 8 (this doesn't exist on Linux, it's only Solaris, do "mysqladmin var | grep concurrency to see that this variable doesn't exist on Linux, you 'll only see innodb_thread_concurrency return which is a different variable)
33 join_buffer_size = 10M
34 max_heap_table_size = 64M
35 tmp_table_size = 64M
------解决方案--------------------
统计数据没什么技巧 内存开大点
用infobright引擎更好
------解决方案--------------------
将unix_timestamp('2012-07-01 09:00:00')、unix_timestamp('2012-07-31 15:00:00')
用变量
OR
字符串累加生成SQL语句,再执行试试
------解决方案--------------------
一次性导出这么多数据 明显会慢了。
听一楼的 把数据放到infobright里面了在弄,只是查询的话 效率高很多。
cpu过高 大量的慢查询是主要的罪魁祸首、
------解决方案--------------------
利用好索引,也不会太慢。既然是定时了,说明执行不频繁,慢点就慢点,可以放到从上去执行,不影响其他业务。
------解决方案--------------------
time列上搞个cluster index试试。