惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
N
News and Events Feed by Topic
N
News | PayPal Newsroom
SecWiki News
SecWiki News
P
Privacy International News Feed
T
Troy Hunt's Blog
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
L
LINUX DO - 热门话题
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Security Latest
Security Latest
AWS News Blog
AWS News Blog
S
Secure Thoughts
W
WeLiveSecurity
H
Heimdal Security Blog
T
Threat Research - Cisco Blogs
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Security @ Cisco Blogs
G
GRAHAM CLULEY
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Spread Privacy
Spread Privacy
L
Lohrmann on Cybersecurity
C
CERT Recently Published Vulnerability Notes
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
Google Online Security Blog
Google Online Security Blog
Cisco Talos Blog
Cisco Talos Blog
雷峰网
雷峰网
Cloudbric
Cloudbric
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google DeepMind News
Google DeepMind News
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
Latest news
Latest news
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
D
Docker
Recent Announcements
Recent Announcements
博客园 - 【当耐特】
H
Help Net Security
博客园 - 司徒正美
TaoSecurity Blog
TaoSecurity Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Check Point Blog
博客园 - 叶小钗

博客园 - 迷途

Axure教程 | 轻量级的后台原型框架 Axure:侧导航收缩与展开 SQLSERVER数据库调优 MySQL用GROUP BY分组取字段最大值或最新一条 Sqlserver 创建表角本 在SQLSERVER中处理特殊字符以及空格。 索引优化--汇总 游标简单使用 SQL Server 索引优化-----数据库引擎优化顾问 SQL Server 索引优化 ——索引缺失 SQL Server 索引优化——无用索引 win7远程服务器发生身份验证错误,要求的函数不受支持 库龄分析-先进先出法 sql server 数据库创建链接服务器 SQL Server 2008 R2中配置作业失败后邮件发送通知 sqlserver 使用脚本创建作业 SQL分组取每组前一(或几)条记录(排名) SQL SERVER 中如何用脚本管理作业 sqlserver2008 查看数据库自带的索引建议
Mysql索引总结
迷途 · 2020-04-01 · via 博客园 - 迷途

日期类型可以直接和string格式的字符串比较

select * from xxx where event_time>'2018-06-02' 可以使用索引, mysql默认会把后面的字符串转成date类型。可以使用between and

select * from xxx where date(event_time)>'2018-06-02'   不能使用索引

如果时间戳日期和时间都要比较, 最好使用两个字段保存这个时间戳, 这样可以利用索引

select * from xxx where event_time>1239237428734; --  使用错误, 不能这么用。可以使用from_unixtime()将数字转成日期类型

 将date和time合并成一个datetime

select str_to_date(concat(ICDate,' ',ICTime),'%m/%d/%y %h:%i:%s %s')   from XXXX

参考: https://stackoverflow.com/questions/2758486/mysql-compare-date-string-with-string-from-datetime-field

其他索引总结:

where条件等号两边字段类型不同,不走索引

like 'XXX%' 走索引, '%XXX%'不走索引

对字段进行函数运算不走索引

组合索引 只使用后面的字段不走索引,使用前后的字段走索引. 第一个字段有参于(而且字段类型匹配 没有函数运算),那么会走索引, 第一个字段可以在sql中的任意位置

 组合索引遇到第一个不等值条件 即中断后面字段使用索引

 字段类型不匹配,不走索引

 示例:

name varchar, addr varchar, age int。 创建组合索引为name + addr + age

select * from t_user where name like '123%' and age>19;  走索引 type=range

select * from t_user where age>19 and name like '123%' ;  走索引 type=range

select * from t_user where name =123 不走索引 type=all

select * from t_user where name='123' 走索引 type=ref

select * from t_user where addr like '上城%' and age>30; 不走索引 type=all

explain 是否使用了索引

type=ALL是全表扫描

只要不是ALL, 都能使用索引,只是使用索引的方式不同,性能也有差异==>依次从好到差:system,const,eq_ref,ref,fulltext,ref_or_null,unique_subquery,index_subquery,range,index_merge,index,ALL

关于explain各个字段的解释:https://www.cnblogs.com/david97/p/8072164.html

索引不是越多越好, 两个index进行merge有时还不如只使用一个index

组合索引创建的依据:select distinct(xxx)/count(*) 值越大说明区分度越高 组合索引的价值越高 

什么时候创建组合索引?  单列上查询出来的数据量都很大,但是两个组合查询的结果很小 ,此时创建组合索引就比较有意义

 (原始的离线度都小,组合的离散度会大???)    0.8*0.8=0.64       0.8*0.5=0.4    如果整体的数据量级别很大,也有点效果

索引的类型

 BTREE的时间复杂度: https://blog.csdn.net/weixin_38399962/article/details/79409118

orderby 是否使用索引

https://my.oschina.net/u/912810/blog/325177

orderby用到的索引和where中的索引如果一致, 可以提升不少性能

字符类型的索引需要指定长度

ALTER TABLE t_yyy ADD INDEX `xxx` (`request_type` ASC, `request_param`(15) ASC);