如何加入索引语句?

yuezixi 2003-10-25 02:55:58
假设有一存储过程:(对两个表进行联合查询)
CREATE procedure orderselect
@orderform varchar(15)='',
@types nvarchar(15)=''
AS
select distinct
a.orderform,a.orderdate,a.clientid,b.types,b.resname,b.unit,b.orderqty,
b.orderprice,b.moneys,b.criterionprice,b.remark,a.subscription,a.consignmentdate,a.consignmentlocus,a.dealwithman,a.PO,a.remark2,b.states from ordermaster a,orderdetail b
where a.orderform=b.orderform
and a.orderform like '%'+@orderform+'%'
and b.types like '%'+@types+'%'
查询结果量很大,导致速度很慢,请问在此基础上如何创建索引?
...全文
114 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
LoveSQL 2003-10-25
  • 打赏
  • 举报
回复
你使用里like语句,索引好像是不起作用的、。
建议改进一下查询方式,然后在创建合适索引。
welyngj 2003-10-25
  • 打赏
  • 举报
回复
那能怎么办呢?
yuezixi 2003-10-25
  • 打赏
  • 举报
回复
在上过程中只有两个查询条件,那必然要简单,但真正的过程有十几个查询条件,岂不是需要对所有条件都进行索引呢?
lumina 2003-10-25
  • 打赏
  • 举报
回复
关注。
welyngj 2003-10-25
  • 打赏
  • 举报
回复
在建一个索引:
create index index_types on orderdetail(types)
没有必要过程中加上索引条件。
welyngj 2003-10-25
  • 打赏
  • 举报
回复
for example;
create index index_ordform on ordermaster(orderform)
yuezixi 2003-10-25
  • 打赏
  • 举报
回复
能否在此过程中加上索引条件?
lynx1111 2003-10-25
  • 打赏
  • 举报
回复
在表上创建索引就行了

34,874

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧