gladness 的blog

在SQL中使用now()导致的性能下降(MySQL)

做数据库调优,一个简单的tip就使性能提升一大块时,被帮助的人自然是高兴而且感激,我也是满心欢喜。用所学帮助了他人,也说明还是有一技之长的,有一门能够养活自己的手艺。也算是手艺人啊。

同事让我帮助优化,在slow query log里发现有两个SQL执行的次数最多,并且每次都在两秒以上。用explain看了,也未发现索引使用方面的问题。
最后把怀疑的目光落在了SQL结尾处的>=now()上,now()每次都需要从系统中取,因此可能会导致无法使用query cache。
了解了一下需求,实际这里并不需要当时的时刻,只需要当天的日期就行了。因此建议同事把>=now()改成>=当前日期,而当前日期在程序中取得。

个人涂鸦: 

mysqldump死住(实际是导致mysqld crash)

在MySQL 5.0.16上,用mysqldump导出数据,mysqldump半天没反应。
操作系统是RHEL4.0。

看日志
*** glibc detected *** free(): invalid pointer: 0xb17d60b0 ***
mysqld got signal 6;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8388600
read_buffer_size=131072
max_used_connections=2
max_connections=100
threads_connected=2
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 225791 K

技术相关: 
个人涂鸦: 
Subscribe to RSS - gladness 的blog