2017年8月10日

sql技巧

摘要: 1、负向条件查询不能使用索引 2、前导模糊查询不能使用索引 3、数据区分度不大的字段不宜使用索引 4、在字段上计算不能命中索引 5、如果业务大部分是单条查询,使用Hash索引性能更好 B-tree索引的时间复杂度是O(log(n)) Hash索引的时间复杂度是O(1) 6、允许为null的列,查询有 阅读全文

posted @ 2017-08-10 17:24 长风剑客 阅读(117) 评论(0) 推荐(1) 编辑

mysql索引案例分析

摘要: 表结构 order (oid,date,uid,status,money,time) oid主键 date 普通索引 uid用户id 普通索引 status 普通索引 select * from order where status != 2 select * from order where st 阅读全文

posted @ 2017-08-10 17:08 长风剑客 阅读(323) 评论(0) 推荐(0) 编辑

2017年8月9日

mysql limit分页查询效率

摘要: 前提:id是主键 select * from `order` limit 1000000 , 30 当数据量大的时候改写成下面的 select * from `order` where id >= (select id from `order` order by id limit 1000000 , 阅读全文

posted @ 2017-08-09 17:53 长风剑客 阅读(243) 评论(0) 推荐(0) 编辑

mysql exists与in的区别

摘要: select * from user where exists (select * from order where user.id = order.user_id) exists会先查前面的表(user) 然后再和后面的表(order)关联筛选出结果 select * from user wher 阅读全文

posted @ 2017-08-09 17:17 长风剑客 阅读(190) 评论(0) 推荐(0) 编辑

2017年8月7日

mysql索引概况

摘要: 聚集索引:聚集索引决定数据在磁盘上的物理排序,一个表只能有一个聚集索引,一般用primary key来约束 非聚集索引:它并不决定数据在磁盘上的物理排序,索引上只包含被建立索引的数据,以及一个指向数据物理位置的指针 联合索引:多个字段上建立索引,能够加速复核查询条件的检索 索引覆盖:被查询的列能够用 阅读全文

posted @ 2017-08-07 17:38 长风剑客 阅读(102) 评论(0) 推荐(0) 编辑

linux文件

摘要: 使用命令ls -l 或者 ll查看文件 格式 常见的文件类型:d 目录 - 文件 l 链接 设置文件属性:r => 4 , w => 2 , x => 1 chgrp 设置文件/目录所属组 chown 设置文件/目录属主 阅读全文

posted @ 2017-08-07 11:08 长风剑客 阅读(85) 评论(0) 推荐(0) 编辑

2017年8月3日

centos7添加环境变量

摘要: 截图第三行包含了一些配置文件 我们打开/etc/profile.d目录 建立一个go.sh,写入一下内容 export GOROOT=/usr/local/goexport GOBIN=$GOROOT/binexport PATH=$PATH:$GOBINexport GOPATH=/root/go 阅读全文

posted @ 2017-08-03 16:57 长风剑客 阅读(610) 评论(0) 推荐(0) 编辑

2017年7月29日

mysql 索引操作

摘要: 增加索引 alter table table_name add index(columes) alter table table_name add primaty key (colume) alert table table_name add unique(colume) 删除索引 alter ta 阅读全文

posted @ 2017-07-29 17:59 长风剑客 阅读(91) 评论(0) 推荐(0) 编辑

mysql慢查询

摘要: 查看相关慢查询参数 show variables like '%slow_query%' show varialbes like '%long_query_time%' 阅读全文

posted @ 2017-07-29 11:17 长风剑客 阅读(108) 评论(0) 推荐(0) 编辑

mysql5.7用户管理

摘要: 添加用户 命令:create user 'username'@'host' identified by 'password' 例子:create user 'changfeng'@'%' identified by '111111' 配置用户权限 命令:grant privileges on dat 阅读全文

posted @ 2017-07-29 11:08 长风剑客 阅读(137) 评论(0) 推荐(0) 编辑

导航