mysql中的SQL分析工具
Another Look at MySQL 5.1's SQL Diagnostic Tools
http://dev.mysql.com/tech-resources/articles/mysql_51_diagnostic_tools.html 数据库的性能决定因素:
(1)数据库的设计
(2)SQL代码 可以用以下几种方法来解决一些性能问题:
(1)索引
(2)水平分区
(3)列适应的表
column-oriented dbms(http://en.wikipedia.org/wiki/Column-oriented_DBMS#Implementations)
一般表数据文件是按行存储,如:某一表被定义为id,name,desc,则按行存储为:
1,name1,desc1;2,name2,desc2;…
而按列存储为:
1,2;name1,name2;desc1,desc2;… 数据库性能分析方法:
Bottleneck analysis – what is my database, user community, and SQL code waiting on?
Workload analysis – who's logged on and what work are they performing?
Ratio analysis – what do rules-of-thumb statistics say about my performance? 相关的分析命令:
mysql日志分析慢查询日志,一般日志,错误日志
日志可以存在表中,也可存在数据文件中
指定日志存在哪:set global log_output='table'(CSV (comma separated value) engine) or 'file'
日志存的表:mysql.general_log(一般日志)和mysql.slow_log(慢查询日志)
指定日志存的文件:
SET GLOBAL general_log_file=’/tmp/general.log’;
SET GLOBAL slow_query_log_file=’/tmp/slow.log’;
开启/关闭慢查询日志:set global slow_query_log=1/0;
慢查询的threshold:set global long_query_time=1;(秒)
开启/关闭查询日志:set global general_log=1/0;
开启查询profile:set profiling=1;
显示所有profile:show profiles\G
相关文档:
zz linux yum安装mysql后要注意的一些初始化问题
我的服务器装的是centos 5.3,由于最开始安装做了详细的记录,所以整个过程也是轻车熟路,一路yum下来,就搞定了,然后就是数据库、网站的搬家,轻松搞定~
可是今天在家看了下公司的网站,问题出来了~ 有些产品点击查看详细信息的时候,找不到网页~经过一番思考,发现是mysql ......
1.首先,设置数据库支持中文gb2312/gbk。
具体方法:
打开mySQL文件夹,修改my.ini配置文件。
[client]
port=3306
default-character-set=gb2312
以及
[mysqld]下的
default-character-set=gb2312
修改,保存,重启。若设为System服务,可以在控制面板-管理工具-服务中找到mySQL服务,重启。
2.保证Web ......
select 1 from table;与select anycol(目的表集合中的任意一行) from table;与select * from table 从作用上来说是没有差别的,都是查看是否有记录,一般是作条件查询用的。select 1 from 中的1是一常量(可以为任意数值),查到的所有行的值都是它,但从效率上来说,1>anycol>*,因为不用查字典表。 ......