Solved

Speed Up Stored Procedure sql server 2005 express

Posted on 2010-11-11
5
510 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Insert statement is inserting duplicate records 15 63
SQL Server 2012 express 24 40
TSQL mapping detailed records to group records 9 60
Query to return total 6 22
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…
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

827 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