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

推荐订阅源

U
Unit 42
Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
I
InfoQ
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
量子位
博客园 - 叶小钗
月光博客
月光博客
IT之家
IT之家
G
Google Developers Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享

博客园 - 水寒

C++ string 详解 (转)Cstring转char、string、int等数据类型的方法 (转)进程通信(用户自定义消息,用户注册消息,windows剪贴板,WM_COPY, 内存映射,对目标进程的内存) ACE WSA Startup not initialized 问题 21个值得深思的故事! C++内存管理详解 下载Eclipse解压后运行出现问题,出现了jvm terminated.Exit code=-1的错误 Java虚拟机(JVM)中的内存设置详解 每天读一遍,慢慢的你就变了 可以有效改进项目管理技能的十个过程 再次写给我们这些浮躁的程序员 vbcrlf常数 vc字符串函数大全 C++sprintf()函数 UDP组播 C#简单组播示例 一个字符转换引发的问题!诡异..... 再看字节对齐! C++虚函数表解析(转)
sqlite 索引优化方法
水寒 · 2011-05-29 · via 博客园 - 水寒

本文摘自:http://www.cnblogs.com/analyzer/articles/1400122.html

速度测试结果:

1) select count(*) from t1,t3 where t1.word2=t3.word2;
很慢(t3.word2上没有索引)
2) select count(*) from t3,t1 where t1.word2=t3.word2;
很慢(t1.word2上没有独立索引)
3) select count(*) from t1,t2 where t1.word2=t2.word2;
很快(t2.word2上有索引)
4) select count(*) from t2,t1 where t1.word2=t2.word2;
很慢(t1.word2上没有独立索引)
5) select count(*) from t1,t2 where t1.num=t2.num;
很快(t2.num上有索引)
6) select count(*) from t2,t1 where t1.num=t2.num;
很快(t1的复合索引中,第一个列是num)
7) select count(*) from t1,t3 where t1.num=t3.num;
很慢(t3.num上没有索引)
8) select count(*) from t3,t1 where t1.num=t3.num;
很快(t1的复合索引中,第一个列是num)

结论:

1、索引可以大大加快查询速度

2、当有交叉查询时,from a,b两个表,取决于b表是否有索引

3、当b上的索引不是独立索引时,查询速度取决于非独立索引的第一个字段