易截截图软件、单文件、免安装、纯绿色、仅160KB

mysql索引的一个技巧

针对select * from table where col1 > number order by col2 desc。
其实按照常规的方法可以这样设计:key(col1, col2)
但是这种办法在mysql里不算是理想的,where条件里限定索引前部分是一个范围的情况下后面的order by还是会有filesort。如果where条件里限定索引前部分是一个常量,那么order by就会有效利用索引。例如:select * from table where col1 = number order by col2 desc,explain的结果就不错。
为了让它能够利用上索引并且消除filesort,可以这样设计
索引:key(col2,col1);
select * from table where col2 > min_value and col1 > number order by col2 desc;
这里where条件里同时执行了索引的两个列,并且为了保证逻辑一致,对col2列的限定条件等效于无限定。
这样mysql就能很好的利用索引了。这个技巧在mysql high performance2里也有提过.


相关文档:

mysql的字符串函数

对于针对字符串位置的操作,第一个位置被标记为1。
ASCII(str) 返回字符串str的最左面字符的ASCII代码值。如果str是空字符串,返回0。如果str是NULL,返回NULL。
mysql> select ASCII('2');
-> 50
mysql> select ASCII(2);
-> 50
mysql> select ASCII('dx');
-> 100
也 ......

MySQL调优-编译篇

安装时的优化
(以下测试数据都来自于mysql的官方网站)
不要用rpm或其他二进制方式安装
要用源代码自己编译
如果是奔腾系统,推荐用pgcc编译器
且使用-O6的编译参数
这样编出来的mysql比用gcc2.95的要快1%
仅用用得着的字符集编译MySql
mysql目前支持多达34种不同的字符集(mysql4.1.11)
但我们常用的也无非就是lati ......

MySQL: Connect MySQL GUI tools to WAMP 2.0

Connect MySQL GUI tools to WAMP 2.0 Posted by: Vladislav Sadykov () Date: January 24, 2009 09:31AM Hay, I have a problem with MySQL database. I have installed WAMP 2.0 server on my Windows machine and now I would like to connect it with MySQL GUI tools 5. The problem is that at the startup of ......

MySQL保留关键字

MySQL保留关键字
    create table option (oid integer not null auto_increment, oname varchar(255), oinf varchar(255), ovotes integer, oimage varchar(255), ovideo varchar(255), oaudio varchar(255), octime varchar(255), ocuname varchar(255), omtime varchar(255), omuname varchar(255 ......

快速重置MySQL用户密码

 
1、停止正在运行的MySQL进程
    
Linux下,运行 killall -TERM mysqld
     Windows下,如果写成服务的可以运行:net stop mysql,如未加载为服务,可直接在任务管  理器中进行关闭。
2、以安全模式启动MySQL
    
Linux下,运行 mysqld_sa ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号