Solved

Performance  tuning  SQL

Posted on 2011-02-15
5
468 Views
Last Modified: 2012-05-11
Experts -

I've a very simple SQL which is performing very poorly.  Most of the time its waiting for Memory/CPU.

Clustered index on PrimaryKey (ID).
Non-Clustered index on NBR

I've nested loop with Non-clustered Seek and Key Lookup on NBR. Is that a normal?

This table has 2 million rows and the rows are not contained in 1 single page.

I can not remove the STARS in the SQL for this time.

Any ideas?

Thanks,

~sve.


ALTER PROCEDURE [dbo].[GetNbr]
	@nbr nvarchar(50)
WITH RECOMPILE	
AS
BEGIN
	SET NOCOUNT ON;
	
	SELECT * FROM big_2milrows_table with(nolock)
	WHERE Number=@NBR
	
END

Open in new window

0
Comment
Question by:sventhan
  • 3
5 Comments
 
LVL 40

Accepted Solution

by:
Sharath earned 250 total points
ID: 34900687
What is the data type of Number column in your table? If it is int, why don't you pass the @nbr  parameter as int?
0
 
LVL 18

Author Comment

by:sventhan
ID: 34900807
Its a varchar(50). Its actually a phone number. Thanks.
0
 
LVL 50

Assisted Solution

by:Lowfatspread
Lowfatspread earned 250 total points
ID: 34900895
then change the procedure parameter to varchar(50) from nvarchar(50)

when was the last time you rebuild the index?

how many rows are returned for your nbr?

what is the row size?
0
 
LVL 18

Author Closing Comment

by:sventhan
ID: 34900921
Thanks. The problem is something else.
That got fixed.
0
 
LVL 18

Author Comment

by:sventhan
ID: 34901714
@ Lowfatspread

It was the issue with data type mismatch.

Thanks.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Log Backup 2 13
Scheduling Jobs for Execution: 4 16
Troubleshooting Methodology - steps 3 22
SQL JOIN + SUBQUERY? 3 15
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now