复制my-default.ini文件命名为my.ini 内容如下 [client]
port=3306
default-character-set=utf8 [mysqld]
port=3306
character_set_server=utf8
basedir=C:\mysql\mysql-5.
【mysql】 【配置】 【系统环境】 【utf-8】 点击查看原文>
记得在很久以前我在公司内部做过一次MySQL优化分享里面说到一个使用延迟关联实现排序分页类型SQL的优化,这个案例在《高性能MySQL》的第二版还是第三版也有提及。
延迟关联:通过覆盖索引返回所需数据行的主键,再通过主键获取所需数据。
这里我们来看一个使用延迟关联优化排序分页SQL的案例:
123456789101112131415 |
mysql> select sql_no_cache * from t_user_log where appname = '发号中心' order by logintime limit 1000000,1;+---------+-----------+--------------------------+--------------+-----------------+------------------------------------+------------+-----------+-----------+| id | uid | username | appname | loginip | loginlocation | logintime | logintype | useragent … |
记得在很久以前我在公司内部做过一次MySQL优化分享里面说到一个使用延迟关联实现排序分页类型SQL的优化,这个案例在《高性能MySQL》的第二版还是第三版也有提及。
延迟关联:通过覆盖索引返回所需数据行的主键,再通过主键获取所需数据。
这里我们来看一个使用延迟关联优化排序分页SQL的案例:
123456789101112131415 |
mysql> select sql_no_cache * from t_user_log where appname = '发号中心' order by logintime limit 1000000,1;+---------+-----------+--------------------------+--------------+-----------------+------------------------------------+------------+-----------+-----------+| id | uid | username | appname | loginip | loginlocation | logintime | logintype | useragent … |
MySQL的查询执行计划中,Extra列经常会出现“Using where; Using index”。
MySQL官方手册解释:
Using index
The column information is retrieved from the table using only
information in the index tree without having to do an
additional seek to read the actual row. This strategy
can be used when the query uses only columns that are part of a
single index.
Using where
A WHERE clause is used to
restrict which rows to match against the next
table or send to the client. Unless you specifically intend to
fetch or examine all rows from the table, you may have something
wrong in your query if the Extra value is not Using where and the
table join type is ALL or index.
这表明:
Using index不读数据文件,只从索引文件获取数据
Using …
[获取更多]
sysbench是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况。
目前sysbench代码托管在launchpad上,项目地址:https://launchpad.net/sysbench(原来的官网 http://sysbench.sourceforge.net
已经不可用),源码采用bazaar管理。
一、 下载源码包
安装epel包后以便安装bzr客户端:
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
然后就可以开始安装bzr客户端了:
yum install bzr
之后,就可以开始用bzr客户端下载tpcc-mysql源码了。
cd /tmp bzr branch lp:sysbench
MySQL中文网便捷下载地址:
…[获取更多]
如果使用如下语句获取全部数据, 通常,多数数据库都会执行全表扫描.
select * from t1;
但是,如果查询的列对象,全部是某一个索引的一部分,则MySQL会自动识别,查询执行计划也会把全表扫描转变为索引扫描.
如:
mysql> show create table t1;
+-------+-----------------------------
| Table | Create Table
+-------+-----------------------------
| t1 | CREATE TABLE `t1` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
+-------+-----------------------------
INSERT INTO t1 VALUES (1), (2), (3);
查看执行计划:
mysql> explain select * from t1;
+----+-------------+-------+------------+-------+---------------+---------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | …