Solved

Speed Up Stored Procedure sql server 2005 express

Posted on 2010-11-11
5
511 Views
Last Modified: 2012-05-10
sql server 2005 express  

I have a stored procedure that I would like to speed up in someway.

I'm using the "like"  operator...


Is there another way the same results but faster... ?


Thanks
fordraiders

USE [DescMatchGisXref]
GO
/****** Object:  StoredProcedure [dbo].[get_View_SAP_Data_Grid1]    Script Date: 11/11/2010 11:25:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[get_View_SAP_Data_Grid1]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[get_View_SAP_Data_Grid1] @param3 nvarchar(100)  
AS	
SELECT     dbo.SapData.MFRNUM, dbo.SapData.MFRNAME, dbo.SapData.WWGDESC, dbo.SapData.ITEM, dbo.SapData.XREF, dbo.SapData.SPIN, 
dbo.SapData.REDBOOKNUM, dbo.SapData.WWGMFRNAME, dbo.SapData.WWGMFRNUM, WwgExtra.dbo.SapAltData.ALT1, 
WwgExtra.dbo.SapAltData.ALT1SPIN, dbo.SapData.RICHTEXT, dbo.SapData.COMMENTS, WwgExtra.dbo.SapAltData.ALT1DESC, 
WwgExtra.dbo.SapAltData.ALT1DESC2, WwgExtra.dbo.WwgExtra.GREEN, WwgExtra.dbo.WwgExtra.SEGMENT, 
WwgExtra.dbo.WwgExtra.PRIVATE_LABEL
FROM dbo.SapData INNER JOIN
WwgExtra.dbo.WwgExtra ON dbo.SapData.ITEM = WwgExtra.dbo.WwgExtra.ITEM INNER JOIN
WwgExtra.dbo.SapAltData ON WwgExtra.dbo.WwgExtra.ITEM = WwgExtra.dbo.SapAltData.ITEM
WHERE SapData.MFRNUM LIKE '''' + @param3 + ''%''

Open in new window

0
Comment
Question by:fordraiders
  • 2
  • 2
5 Comments
 
LVL 11

Assisted Solution

by:David Kroll
David Kroll earned 250 total points
ID: 34113878
I'd put (nolock) after each table name

FROM dbo.SapData (nolock) INNER JOIN
WwgExtra.dbo.WwgExtra (nolock)

Also make sure that you have indexes on the fields that you are joining the tables on (SapData.ITEM and SalAltData.ITEM).  Also put an index on SapData.MFRNUM.
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 250 total points
ID: 34113901
the problem here is the like operator,the only way to improve the like operation here is to have full text indexing on that column, and modify your query accordingly. but it can add some overhead to the system
0
 
LVL 3

Author Comment

by:fordraiders
ID: 34115045
WHAT DOES "nolock"  DO never seen that before ?
0
 
LVL 11

Expert Comment

by:David Kroll
ID: 34115055
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 34133612
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS SQL page split per second is high 19 122
TSQL mapping detailed records to group records 9 65
Please help for the below sql query. 1 29
How come this XML node is not read? 3 25
by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question