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

推荐订阅源

Forbes - Security
Forbes - Security
A
Arctic Wolf
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
Lohrmann on Cybersecurity
Martin Fowler
Martin Fowler
A
About on SuperTechFans
P
Palo Alto Networks Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
大猫的无限游戏
大猫的无限游戏
Cisco Talos Blog
Cisco Talos Blog
P
Proofpoint News Feed
D
DataBreaches.Net
Cyberwarzone
Cyberwarzone
T
Tor Project blog
IT之家
IT之家
P
Proofpoint News Feed
Help Net Security
Help Net Security
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
CXSECURITY Database RSS Feed - CXSecurity.com
Microsoft Azure Blog
Microsoft Azure Blog
V2EX - 技术
V2EX - 技术
K
Kaspersky official blog
Hugging Face - Blog
Hugging Face - Blog
MongoDB | Blog
MongoDB | Blog
B
Blog
N
News and Events Feed by Topic
The Cloudflare Blog
S
Schneier on Security
P
Privacy & Cybersecurity Law Blog
T
The Blog of Author Tim Ferriss
Recorded Future
Recorded Future
Last Week in AI
Last Week in AI
The Last Watchdog
The Last Watchdog
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
LangChain Blog
I
InfoQ
F
Full Disclosure
The Register - Security
The Register - Security
阮一峰的网络日志
阮一峰的网络日志
H
Hacker News: Front Page
V
V2EX

博客园 - 迷途

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);