select 慢的问题,请教大家!
Select sffid,receSeriNoFrom sf03
Where1=1
And currency Matches 'CNY'
and receserino='R'
And receSeriNo Matches 'R6542240120070800157'
这个sql提取很快,run完马上就出来了。
Select sffid,receSeriNo
From sf03
Where1=1
And currency Matches 'CNY'
and receserino='R'
And receSeriNo Matches 'R6542240120070800157'
And receserino='R'
这个sql却很慢,至少要等1分钟。
为什么?
sf03里有283万条数据,具体表的主健和索引是这样的:
primary key (receserino)constraint "sff".sf03_p
);
revoke all on "sff".sf03 from "public";
create index "sff".sf03i1 on "sff".sf03 (dealno,suffixno) using
btree ;
create index "sff".sf03i2 on "sff".sf03 (deskdate,ksdm) using
btree ;
create index "sff".sf03i3 on "sff".sf03 (paydate,ksdm) using btree
;
create index "sff".sf03i4 on "sff".sf03 (receiptno,versionno,receiptkind)
using btree ;
create index "sff".sf03i6 on "sff".sf03 (ksdm,procdate) using
btree ;
create unique index "sff".sf03iid on "sff".sf03 (sffid) using
btree ;
为什么加了条件就慢呢?统计更新也做了
问题增加的描述
查看优化结果的时候发现语句:
Select sffid,receSeriNo
From sf03
Where1=1
And currency Matches 'CNY'
and receserino='R'
And receSeriNo Matches 'R6542240120070800157'
先过滤receSeriNo = 'R6542240120070800157'
再过滤receserino='R'
而语句:
Select sffid,receSeriNo
From sf03
Where1=1
And currency Matches 'CNY'
and receserino='R'
And receSeriNo Matches 'R6542240120070800157'
and receserino='R'
先过滤receserino='R' 就慢到这里了
再过滤(receSeriNo = 'R6542240120070800157' and receserino='R')
这不是SB优化吗?怎么回事啊??
终于找到原因了,但是不知道为什么?
我倒完数据库后只做了update statistics.昨天对数据库做了udate statistics high后就好了。
真是没有想到这个居然能影响到优化的结果 http://www.chinaunix.net/jh/20/361314.html 咳咳,LZ是PICC的吧 咳咳,同意,sff
picc.晕,看来在这混的人不少啊.
页:
[1]