正确的使用Bitmap Index (位图索引)来代替普通索引,可以成百上千倍的提高SQL查询性能。
先来看看Bitmap索引和普通索引的区别。我来在Patient表的Sex字段上创建两个索引
- idxSex: 普通索引
- bidxSex: bitmap索引
然后创建10个病人数据,查看索引的内容:
# 普通索引
^User.PatientI("idxSex"," F",1) = ""
^User.PatientI("idxSex"," F",6) = ""
^User.PatientI("idxSex"," F",8) = ""
^User.PatientI("idxSex"," M",2) = ""
^User.PatientI("idxSex"," M",3) = ""
^User.PatientI("idxSex"," M",4) = ""
^User.PatientI("idxSex"," M",5) = ""
^User.PatientI("idxSex"," M",7) = ""
^User.PatientI("idxSex"," M",9) = ""
^User.PatientI("idxSex"," M",10) = ""
# bitmap索引
^User.
.png)
.png)

.png)
.png)
.png)
.png)
.png)


(5).jpg)

.png)

%20(4).jpg)
.png)
.png)
.png)

