您好,欢迎来到九壹网。
搜索
您的当前位置:首页sqlite索引优化方法

sqlite索引优化方法

来源:九壹网
sqlite索引优化⽅法

本⽂摘⾃:速度测试结果:

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上的索引不是独⽴索引时,查询速度取决于⾮独⽴索引的第⼀个字段

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务