Solved

Performance  tuning  SQL

Posted on 2011-02-15
5
469 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

943 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

10 Experts available now in Live!

Get 1:1 Help Now