当前位置:网站首页>为什么 SQL 语句使用了索引,但却还是慢查询?
为什么 SQL 语句使用了索引,但却还是慢查询?
2022-06-09 13:43:00 【InfoQ】
一、索引与慢查询
CREATE TABLE `t` (
`id` int(11) NOT NULL,
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `a` (`a`)
) ENGINE=InnoDB;
insert into t values (1, 1, 1), (2, 2, 2);


二、索引的过滤性



三、索引的扫描行数

alter table t_people add name_first varchar(2) generated always as
(left(name, 1)), add index (name_first, age);
CREATE TABLE `t_people` (
`id` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`info` varchar(255) DEFAULT NULL,
`name_first` varchar(2) GENERATED ALWAYS AS (left(`name`, 1)) VIRTUAL,
KEY `name_first` (`name_first`, `age`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

四、小结
边栏推荐
- Implementation scheme of RTSP video stream real-time playing on web end of webcam
- 入职腾讯外包一个月,我离职了
- Little known beyond relu, it was discovered three years later: the activation functions used by Bert, gpt-2, etc
- 发邮件:错排问题的分析
- C# ListBox用法
- Ffmpeg support for HLS slicing
- 输入一行字符(最多80个),从第location个位置开始,截取number个字符并将其输出。
- FFMPEG对HLS切片的支持
- 数据分析--
- 51 MCU timer 0 is used as time reference and delay function reference
猜你喜欢

Machine learning basics memorandum

【并查集】合根植物(连通块的数数量)

黄金频段乃第四大运营商杀手锏,农民将获得低价5G服务

汇编语言入门-指令与寻址方式

像大脑一样,纳米磁体网络可用于执行类似 AI 的计算处理,可降低能耗

C language structure | linked list

PhD Debate | 自监督学习在推荐系统中的应用

TCP(滑动窗口,流量控制)

U.S. restrictions on sharing security vulnerabilities will throw stones at its own feet, and domestic systems will gain development opportunities

An intranet test for an Express Hotel
随机推荐
Like the brain, the nano magnet network can be used to perform AI like computing processing, which can reduce energy consumption
TCP/IP协议(1)
机器学习基础备忘录
UniswapV2周边合约学习(六)-- ExampleOracleSimple.sol
WordPress地址(URL)修改后打不开网站的解决方法
Avenue to simplicity | how to configure self attention for vit is the most reasonable?
Uniswapv2 peripheral contract learning (VIII) -- exampleswaptoprice sol
元宇宙产业投资全景图,快人一步走进元宇宙新时代!
科研统计分析绘图工具GraphPad Prism 9 for Mac
15 Uncaught TypeError: Cannot set properties of null (setting ‘onclick‘)
I haven't published a thesis for 5 years, and I want to give up my doctoral degree? Ten thousand words self narration of the doctoral director of the University of science and technology of China: he
mysql不能update查询结果集的解决办法
从刚入测试界到薪资翻倍:聊聊我的测试进阶历程,值得借鉴
Is it reliable and safe to open an account for external futures?
Uniswap contract learning -- uniswap uni token
大道至简 | 设计 ViT 到底怎么配置Self-Attention才是最合理的?
代码实现WordPress编写文章可以调整字体字号
Meanings of 10 important concepts and charts in Data Science
线程池创建方式详解
HCIA datacom experiment IPv4 addressing and IPv4 routing basic experiment