测试复合索引在oracle、sql server 、mysql各种情况下是否使用索引
来源:互联网 发布:学龄前儿童教育软件 编辑:程序博客网 时间:2024/05/16 13:47
今天没有事验证一下复合索引在不同的数据库中的使用情况,仅是测试而已,以一个例子测试,结果如下
首先在oracle,sqlserver, mysql建立表testpayorderinfo 表结构一样,然后插入20w数据
分别创建复合索引(testpayorderid,connid,customerid的复合索引)
以复合索引中的不同条件字段的组合作为条件进行测试
说明:
testpayorderid 对应a
connid 对应b
customerid 对应c
测试结果如下:
sql server:(版本sql server 2008)
select * from testpayorderinfo where testpayorderid=194027 --a 走
select * from testpayorderinfo where connid=257277 --b 走
select * from testpayorderinfo where customerid=1304349 --c 走
select * from testpayorderinfo where testpayorderid=194027 and connid=257277 --ab 走
select * from testpayorderinfo where testpayorderid=194027 and customerid=1304349 --ac 走
select * from testpayorderinfo where testpayorderid=194027 and connid=257277 and customerid=1304349 --abc 走
select * from testpayorderinfo where connid=257277 and customerid=1304349 --bc 走
select testpayorderid,connid,customerid from testpayorderinfo where connid=257277 --b 走
select testpayorderid,connid,customerid from testpayorderinfo where customerid=1304349 --c 走
select testpayorderid,connid,customerid from testpayorderinfo where connid=257277 and customerid=1304349 --bc 走
oracle:(oracle Release 12.1.0.2.0 )
create index ix_com_acc on testpayorderinfo(testpayorderid,connid,customerid)
select * from testpayorderinfo where testpayorderid=194027 --a 走
select * from testpayorderinfo where connid=257277 --b 不走
select * from testpayorderinfo where customerid=1304349 --c 不走
select * from testpayorderinfo where testpayorderid=194027 and connid=257277 --ab 走
select * from testpayorderinfo where testpayorderid=194027 and customerid=1304349 --ac 走
select * from testpayorderinfo where testpayorderid=194027 and connid=257277 and customerid=1304349 --abc 走
select * from testpayorderinfo where connid=257277 and customerid=1304349 --bc 不走
select testpayorderid,connid,customerid from testpayorderinfo where connid=257277 --b 走
select testpayorderid,connid,customerid from testpayorderinfo where customerid=1304349 --c 走
select testpayorderid,connid,customerid from testpayorderinfo where connid=257277 and customerid=1304349 --bc 走
mysql :(Server version: 5.5.47-log MySQL Community Server (GPL))
select * from testpayorderinfo where testpayorderid=194027 --a 走
select * from testpayorderinfo where connid=257277 --b 不走
select * from testpayorderinfo where customerid=1304349 --c 不走
select * from testpayorderinfo where testpayorderid=194027 and connid=257277 --ab 走
select * from testpayorderinfo where testpayorderid=194027 and customerid=1304349 --ac 走
select * from testpayorderinfo where testpayorderid=194027 and connid=257277 and customerid=1304349 --abc 走
select * from testpayorderinfo where connid=257277 and customerid=1304349 --bc 不走
select testpayorderid,connid,customerid from testpayorderinfo where connid=257277 --b 走
select testpayorderid,connid,customerid from testpayorderinfo where customerid=1304349 --c 走
select testpayorderid,connid,customerid from testpayorderinfo where connid=257277 and customerid=1304349 --bc 走
测试结果:
oracle和mysql 走的索引是一样的,sql server 只要是复合索引中的任何一个字段都走索引
- 测试复合索引在oracle、sql server 、mysql各种情况下是否使用索引
- 复合索引在什么情况下使用
- ORACLE 复合索引在什么情况下会被用到
- sql server 复合索引和include索引
- Sql Server 创建索引 、复合索引
- oracle数据库查询Sql语句是否使用索引及常见的索引失效的情况
- 如何获得SQL Server索引使用情况
- 怎样获得SQL Server索引使用情况
- ORACLE复合索引使用 注意事项
- MySql是怎么使用的索引,在哪些情况下会使用到索引
- mysql什么情况下不会使用索引
- ORACLE索引---查看索引是否被sql使用
- 除复合索引外,哪些情况下不适合用索引
- oracle的索引使用:复合索引中的前导索引
- SQL Server学习之复合索引
- SQL Server的复合索引学习
- SQL Server的复合索引学习
- SQL Server的复合索引学习【转载】
- JQuery实现品牌展示
- ios – 使用UINib加载xib文件实现UITableViewCell
- ios 获取当前wifi名称
- android 改变全局字体样式(第三方字体包)
- 使用EJB使用jboss7.0中配置数据源
- 测试复合索引在oracle、sql server 、mysql各种情况下是否使用索引
- iOS常用设计模式:单例
- Javascript自学-1
- LeetCode Problem:Odd Even Linked List
- 随机森林vsGBDT
- 设置tomcat的默认jdk
- 纪念蒟蒻博客第一天
- uestc 250 windy数 【数位dp】
- 137 php 正则表达式2-反向引用