SQL server SQL語句性能差的例子

av最新网址-日韩精品少妇-wwwxxx黄色-好吊色欧美一区二区三区视频-久久午夜av-日韩每日更新-超碰女-日本免费在线一区-久久久久无码国产精品一区李宗瑞-最新av观看-日本sm一区二区

<form id="qllfv"><tbody id="qllfv"><nobr id="qllfv"></nobr></tbody></form>
<tfoot id="qllfv"></tfoot>
<form id="qllfv"><video id="qllfv"></video></form>

<menuitem id="qllfv"></menuitem>


獲得積分
資料庫會員登錄
搜索: [高級搜索]
下載首頁 | 資源分類 | 下載排行
您的位置: 首頁 > 信息化技術(shù) > MSSQL
 
分類導(dǎo)航
下載排行
最新資源
SQL server SQL語句性能差的例子
資源大小:26.69 KB 資源類型:文檔
下載積分: 0
更多
-->
下載統(tǒng)計:總下載:0,本月下載:0,本周下載:0,今日下載:0
發(fā)表評論 錯誤報告 加入收藏夾
資源介紹
()where 中很多or ,會導(dǎo)致性能非常差,
這樣的語句,程序會按blh,cardno,patid,tjbh,一遍遍找數(shù)據(jù)。應(yīng)當(dāng)改為if else
   
                  SELECT  a.*
                        FROM  TJ_TJRYK a (nolock), SF_BRXXK b (nolock), YY_DQDMK c        ,TJ_TJTDK d
                        where a.patid = b.patid  and b.qxdm *= c.id and a.tdxh=d.xh
                                and ((    @codetype =1 and b.blh = @code)
                                    or (@codetype =2 and b.cardno = @code)
                                    or (@codetype in (3,4) and b.patid = @code1)
                                or (@codetype =6 and a.tjbh = @code))  --add 20070611
                        order by a.xh desc
(2)subtring和盡量減少sql語句
--exec usp_mz_ys_gdtxs "00","20080903"--【Ztsql】
CREATE proc usp_mz_ys_gdtxs   
@ysdm  ut_czyh,      
@cxrq  ut_rq16   
   
as   
/**********   
[版本號]4.0.0.0.0   
[創(chuàng)建時間]2006.9.25   
[作者] ziyun     
[版權(quán)] Copyright ? 2004-2004上海金仕達(dá)-衛(wèi)寧醫(yī)療信息技術(shù)有限公司   
[描述]門診醫(yī)生站主界面醫(yī)生信息顯示內(nèi)容   
[功能說明]   
門診醫(yī)生站主界面醫(yī)生信息顯示內(nèi)容   
[參數(shù)說明]   
@Ysdm  ut_czyh, --醫(yī)生代碼     
@cxrq  ut_rq16, --查詢?nèi)掌?nbsp;  
@beginrq ut_rq16, --開始時間   
@endrq  ut_rq16  --結(jié)束時間   
[返回值]   
[結(jié)果集、排序]   
[調(diào)用的sp]   
[調(diào)用實例]   
[修改歷史]   
**********/   
  
declare @hour  varchar(2),@ghlb  ut_bz,@ksdm  ut_ksdm  
select @hour=convert(varchar(2),getdate(),108)  
  
if  @hour<='12'  
begin  
select @ghlb=ghlb,@ksdm=ksdm from GH_GHZDK a(nolock)   
where  a.ysdm=@ysdm and a.jlzt=0 and a.fzbz>0 and a.ghrq like substring(@cxrq, 1, 8)+ '%'   
and substring(a.ghrq,9,2)<='12'

--agg: (1)substring(a.ghrq,9,2)<='12'的性能是非常差的,在這里a.ghrq like substring(@cxrq, 1, 8)+ '%'   
--      and substring(a.ghrq,9,2)<='12' 可以改為a.ghrq>= substring(@cxrq, 1, 8) and a.ghrq<
--      =substring(@cxrq, 1, 8)+’12’and a.ghrq>= substring(@cxrq, 1, 8) and a.ghrq>
--      =substring(@cxrq, 1, 8)+’24’,這樣才可以很好的用到ghrq索引
--     (2)這里如果會取出多條記錄。這樣@ghlb不是會多賦值, 是不是可以加top 1。
end  
else  
begin  
select @ghlb=ghlb,@ksdm=ksdm from GH_GHZDK a(nolock)   
where  a.ysdm=@ysdm and a.jlzt=0 and a.fzbz>0 and a.ghrq like substring(@cxrq, 1, 8)+ '%'   
and substring(a.ghrq,9,2)>'12'  
end  
--agg: substring(a.ghrq,9,2)<='12'的性能是非常差的,在這里a.ghrq like substring(@cxrq, 1, 8)+ '%'   
--      and substring(a.ghrq,9,2)<='12' 可以改為a.ghrq>
--      substring(@cxrq, 1, 8)+’12’,這樣才可以很好的用到ghrq索引
--     (2)這里如果會取出多條記錄。這樣@ghlb不是會多賦值, 是不是可以加top 1。

   
declare  @strsql varchar(1000),   
@zrc int,@zje ut_money,@wjz int   
下載地址
 下載地址1
按字母檢索

下載須知:
大部份資源無需注冊即可下載
需要積分的資源要在會員中心注冊會員并用 積分體系中提示的方法賺取積分才能下載。

免責(zé)聲明:
所有資源只能用于參考學(xué)習(xí),不能用于任何商業(yè)用途,否則后果自負(fù)!