两个在存储过程(CPU,读磁盘占用很多)的优化?该怎么解决
两个在存储过程(CPU,读磁盘占用很多)的优化?
如题,两个存领储过程的优化,请帮忙看看谢谢
第一个存储过程:
存储过程2
------解决思路----------------------
需要提供一些典型的测试数据才好判断,(1)表dbo.edu_Contents、dbo.web_News的数据,(2)传入两个存储过程的参数是什么样式的,(3)这些参数是从哪里得到的,应用系统的界面,还是在其他存储过程中查表查出来的
------解决思路----------------------
根据业务重写查询或者改表结构吧。全文索引不一定什么地方都能用
如题,两个存领储过程的优化,请帮忙看看谢谢
第一个存储过程:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROC [dbo].[sp_Get_News]
--得到所有在该教育局显示的新闻(包括本教育局发布和其他单位分享)
@UnitID text,
@ID nvarchar(100),
@CategoryID uniqueidentifier,
@EduID int
as
select * from
((select Title,c.ID,CategoryID,EduUnitID,PublishTime from dbo.edu_Contents c
where @UnitID like ('%'+cast(c.EduUnitID as nvarchar(10))+'%') and c.SchoolIdList like ('%'+@ID+'%') and IsEnable=1 and CategoryID=@CategoryID and TypeId=1 and NewsState=0)
union
(select w.xj_Title as Title,w.xj_id as ID,w.xj_MenuId as CategoryID,w.xj_unitid as EduUnitID,w.xj_addtime as PublishTime from dbo.web_News w
where @UnitID like ('%' + cast(w.xj_unitid as nvarchar(10)) + '%') and w.xj_eduenable like ('%'+@ID+'%') and xj_Enable=2 and xj_MenuId=@CategoryID and NewsState=0)
union
(select Title,c.ID,CategoryID,EduUnitID,PublishTime from dbo.edu_Contents c
where c.EduUnitID=@EduID and IsEnable=1 and CategoryID=@CategoryID and TypeId=1 and NewsState=0
)) s where 1>0 order by PublishTime desc
存储过程2
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROC [dbo].[sp_Get_sjShareNews]
@UnitID text,@ID nvarchar(100)
as
select * from
(select Title,c.ID,CategoryID,EduUnitID,PublishTime,ClickCounts from dbo.edu_Contents c
where @UnitID like ('%'+cast(c.EduUnitID as nvarchar(10))+'%') and c.SchoolIdList like ('%'+@ID+'%') and IsEnable=1) s
------解决思路----------------------
需要提供一些典型的测试数据才好判断,(1)表dbo.edu_Contents、dbo.web_News的数据,(2)传入两个存储过程的参数是什么样式的,(3)这些参数是从哪里得到的,应用系统的界面,还是在其他存储过程中查表查出来的
------解决思路----------------------
根据业务重写查询或者改表结构吧。全文索引不一定什么地方都能用