Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to tune up this SP
Message
From
31/05/2002 13:25:27
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
How to tune up this SP
Miscellaneous
Thread ID:
00663553
Message ID:
00663553
Views:
37
There is a clustered Index on name field. All the rest fields have a index also.
The query is fast when there is a name field. If the name field is empty the query is slow.
Is there any other way to speed up the query when now name field is specified.

**********************************

CREATE PROCEDURE searchdir
@name char(60) ,
@teleno char(7),
@aliasname char(60),
@doorno char(10),
@streetno char(50),
@locality char(20),
@pincode char(6),
@category char(3),
@aliascat char(3)
AS

set @name = rtrim(@name)+'%'
set @teleno = rtrim(@teleno)+'%'
set @aliasname = rtrim(@aliasname)+'%'
set @doorno = rtrim(@doorno)+'%'
set @streetno = rtrim(@streetno)+'%'
set @locality = rtrim(@locality)+'%'
set @pincode = rtrim(@pincode)+'%'
set @category = rtrim(@category)+'%'
set @aliascat = rtrim(@aliascat)+'%'

select TOP 500 * from dirmaster
where name like RTRIM(@name)
and tele_no like RTRIM(@teleno)
and aliasname like rtrim(@aliasname)
and doorno like rtrim(@doorno)
and streetno like rtrim(@streetno)
and locality like rtrim(@locality)
and pincode like rtrim(@pincode)
and category like rtrim(@category)
and aliascat like rtrim(@aliascat)
order by name
<\pre>
**********
Next
Reply
Map
View

Click here to load this message in the networking platform