为了得出其查询速度快或慢的结论,做了如下实验:
(1)在赵老师的机器上产生了一个10万条记录的表,不过它只有一个长度为1000 类型为varchar 的字段。
(2)在vb程序中书写了如下程序段
dim db as new adodb.connection
dim adoprimaryrs as new adodb.recordset
db.cursorlocation = aduseclient
db.open provider=msdasql;driver={microsoft odbc for oracle};server=zl;uid=zlhis;pwd=his;
adoprimaryrs.cursorlocation = aduseclient
adoprimaryrs.cursortype = adopenstatic
adoprimaryrs.locktype = adlockbatchoptimistic
debug.print time, timer
set adoprimaryrs = db.execute(select name from test where name like '%中国国%' )
debug.print time, timer
(3)经多次运行,并把匹配串改为如'%1%','%aklsdjflsasdfasd%'等,发现所耗时间在5——10秒之间波动,其值与匹配串的长度、返回记录的数量都关系。而与记录集的cursorlocation等属性关系不大。
(4)后来我把匹配串改成'34%'之类的格式,结果所耗时间一般在3秒左右,比较稳定。
(5)最后我把匹配串改成'%34'之类的格式,结果所耗时间与'%34%'差不多。
