Solved

Slow procedures, Sort Warnings and Execution Plans

Posted on 2004-10-07
6
295 Views
Last Modified: 2008-02-01
Experts,

One of my customers (a bank) has a dual processor 4GB database server that, at random times, exhibits extremely slow performance when running one particular procedure.  The database is no more than 8GB in total size so they have enough memory to absorb 50% of their data at a time.  
They are looking to me to resolve their performance.

I have run a basic SQL Profile and the trace reveals, that at the time in question, the proc required a long duration (several minutes!) and gerenated enormous number of reads.  The trace also reports multiple sort warnings although they are coming from different SPIDs which suggests the sort warnings are knock on effect of the rogue proc rather than from the proc itself.

We have extracted the long-running procedure calls from the trace, and when executed via Query Analyser, the proc runs fine.  The execution plan reveals nothing obvious i.e it uses mostly index scans/seeks and no table scans.

I have also checked that the indexes in their live environment match that of our product specification.  All relevant indexes appear to be in place and the indexes are regularly maintained.

So I'm a bit stuck on how to proceed and would like some advice.  Given that they are a bank and this is their live environment, they will be reluctant to release a copy of the database to us.  Hence I am looking for some further diagnostics steps that they can run of the live database

Please help...I'm getting pressure to resolve this.
Thanks
Meowsh
0
Comment
Question by:meowsh
  • 3
  • 2
6 Comments
 
LVL 34

Expert Comment

by:arbert
ID: 12252429
Post the procedure.  Lots of time, the SQL will run faster in Query Analyzer because you don't use parms and just execute the SQL.

I'm guess the proc my be suffering from parameter sniffing.

Brett
0
 
LVL 34

Accepted Solution

by:
arbert earned 250 total points
ID: 12252435
0
 
LVL 15

Expert Comment

by:justinbillig
ID: 12252466
when was the last time thier indexes were rebuild.

Do they do alot of heavy functioning like lots of casting, or substrings, or any other functions like that.

are they using the right datatypes on all thier columns? integer searching / sorting / joining is the fastest.

and the main question ( which i probably know the answer to )

Is there database normalized? Do they have redundant data or repeating groups?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 15

Expert Comment

by:justinbillig
ID: 12252491
0
 
LVL 34

Expert Comment

by:arbert
ID: 12252536
"when was the last time thier indexes were rebuild.

Do they do alot of heavy functioning like lots of casting, or substrings, or any other functions like that.

are they using the right datatypes on all thier columns? integer searching / sorting / joining is the fastest.

and the main question ( which i probably know the answer to )

Is there database normalized? Do they have redundant data or repeating groups?"


If it runs fast in analyzer but not the proc, probably not a structure problem....
0
 
LVL 18

Expert Comment

by:mdougan
ID: 12253960
Hi meowsh,

Some other thoughts... sometimes, intermittent performance problems can result from things such as  not running statistics on tables that have a high degree of inserts/updates/deletes.... or, the production database does not have the same indexes which exist on the development database.... or, the area where the data files are located for the temp db are low on available drive space... this causes lots of paging and can really tank the execution of an innocent query.  Another problem can result from locks... so, when experiencing the performance  hit, take a look at Current Activity, and see what locks are being  held... we've added  the  WITH (NOLOCK) to almost all of our Select statements which only retrieve data for read only access, as that prevents blocking locks on the tables which are used by many other procedures.

Cheers!
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

746 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

13 Experts available now in Live!

Get 1:1 Help Now