sql performance

Hi Experts,

i have an SQL 2008 cluster in my network and the user tell me a very bad performance.
Sometimes they wait 5 minutes to finish a task.

Can you help me and guide me to find these performance killers ?
Eprs_AdminSystem ArchitectAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
This is so general that first you need to check whole box for bottlenecks (CPU, Memory, Disk and Network).
You can do that by running a Performance Monitor. At the same time isn't a bad idea to run the SQL Profiler to check for Blocking Locks and long running queries.
And this is only the beginning...
0
Christopher GordonSenior Developer AnalystCommented:
Here is an  easy script I usually run to check for long running queries and blocking processes:

select	
  session_id
, start_time
, command
, sql_text.text as sql_text
, DB_NAME(database_id) as databaseName
, blocking_session_id
, user_name(user_id)		as	userName
, cpu_time
, query_hash
 

from	sys.dm_exec_requests

outer apply sys.dm_exec_sql_text(sql_handle) sql_text

order by cpu_time desc

Open in new window


Good luck.
0
Eprs_AdminSystem ArchitectAuthor Commented:
Hello,

I have installed the Performance Dashboard.
Here I can see over 70 locks and a lot of parallelism.

Can you explain the parallelism problem please ?
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Parallelism can be explicit (you set it in the query with MAXDOP option) or implicit (the engine will decide to use it or not depending on the conditions) and it's used to split a query execution in many task as existing CPU/core or as many is set by the MAXDOP option.
When well used it can be a perform boost but in the other hand can be a big bottleneck if you use it wrong.

To verify the MAXDOP configured in the SQL Server instance run the following in a New Query window:
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'max degree of parallelism',
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'show advanced options', 0;
GO
RECONFIGURE WITH OVERRIDE;

Open in new window


Can't help you more without seeing the query and the respective query plan.
0
Eprs_AdminSystem ArchitectAuthor Commented:
the script comes with an error:

Meldung 102, Ebene 15, Status 1, Zeile 1 - this is german sorry.

But it says ,ther eis an error near the comma (,)
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
It's right. Was a typo. Here the correct code without the extra comma:
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'max degree of parallelism'
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'show advanced options', 0;
GO
RECONFIGURE WITH OVERRIDE;

Open in new window

0
Eprs_AdminSystem ArchitectAuthor Commented:
ok now it works.
But now all users are at home.
So it shows 0.
0
Eprs_AdminSystem ArchitectAuthor Commented:
during the day I had a lot of locks.
What can I do against these locks ?
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
0 (zero) it's the default value and means use all cores for parallelism. Maybe is not a good value for your query in particular but I can't help you more without seeing the query.

The Performance Dashboard didn't identify the queries causing the locks? You should start working on those queries.
0
Eprs_AdminSystem ArchitectAuthor Commented:
the queries are very long, which ones you need ?
0
Eprs_AdminSystem ArchitectAuthor Commented:
Here I have one long query.
What are the best MAXDOP settings and threshould settings ?

query
MAXDOP = half cores ?
Threshould = 50 ? -> But what is 50 ?
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
No one can't says a good value for a MAXDOP for a query only by looking to the code.
You need to provide the query plan and the server configuration (it's a VM or physical machine? Has hyperthreading on? How many CPU? How many cores?).

By the way, why do you think that query is the one that has bad performance?
0
Eprs_AdminSystem ArchitectAuthor Commented:
This query was found with the performance dashboard.
The SQL Server is physical.
It has 2 CPUs and 8 Cores.

By the way there is an article from Microsoft about this MAXDOP.
They speak about processors less than 8 then put it in.
But do they really mean processors or cores ?
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
They mean cores. But if your server has hyper threading then you need to count only half of the cores and if it's NUMA architecture then you should only count the cores for one CPU.
What you can do with that query in particular is to set MAXDOP=1 so the engine won't parallelize it.
0
Eprs_AdminSystem ArchitectAuthor Commented:
when I have 8 cores, why not to set to 4 ?
And can you explain the threshold value of costs ? What is 50 ?
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
when I have 8 cores, why not to set to 4 ?
If it's a Quadcore NUMA architecture, then it's recommend to set the value to 4. If not, 8 it's the recommend value but since it's only a recommendation, you need to make tests to see if with 4 the performance is better.

And can you explain the threshold value of costs ? What is 50 ?
Sorry, now you lost me. What you mean with this?
0
Eprs_AdminSystem ArchitectAuthor Commented:
How can I check if its NUMA on my server ?
0
Eprs_AdminSystem ArchitectAuthor Commented:
Sorry, now you lost me. What you mean with this?

Here I mean the costs of parallelism. This is also set to 5.
But can you explain this a little bit ? What is 5 ?
What the SQL is doing when a query comes and the costs are set to 5 ?
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
Means that it will parallelize the query to run in 5 cores at same time. If the server has 8 cores, five of them will be used to run the query and the others three cores will be available for other tasks.
0
Eprs_AdminSystem ArchitectAuthor Commented:
Is it not MAXDOP what you mean ?

Someone told me to put the costs to 50.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
Sorry, now I saw your question about the threshold. Where are you using it?
0
Eprs_AdminSystem ArchitectAuthor Commented:
The standard settings on my sql cluster are :

MAXDOP -> 0
Costs -> 5

But I get  a lot of parallelism waits.
I have to change this.

My hardware is :
2 processors of INTEL XEON 5460 at 3.16 GHz

In total I see 8 CPUs in the task Manager.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
Try to change MAXDOP to 4. If you still having locks then reduce it to 1.

Can't see what's COSTS->5
0
Eprs_AdminSystem ArchitectAuthor Commented:
Ok, when I understand the right way, I can choose MAXDOPS until 8.
But 1 is not logic, because this means just one CPU and then parallelism is off.
With MAXDOP=0 means they use default all processors and cores.
0
Eprs_AdminSystem ArchitectAuthor Commented:
The costs are the field over the MAXDOP field : cost threshold for parallelism
This is set to 5 by default. This means 5 seconds.
0
Eprs_AdminSystem ArchitectAuthor Commented:
Do I have to reboot, when I change MAXDOP or THRESHOULD ?
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
Ok, when I understand the right way, I can choose MAXDOPS until 8.
 But 1 is not logic, because this means just one CPU and then parallelism is off.
You should let the engine to chose to use or not the parallelism but since you are telling to always use it will but that doesn't mean that will work better.
From MSDN article (point 3):
"To distinguish between queries that benefit from parallelism and those that do not benefit, The Database Engine compares the estimated cost of executing the query or index operation with the cost threshold for parallelism value. Although not recommended, users can change the default value of 5 using sp_configure. "
So you shouldn't touch the costs option also.
Do I have to reboot, when I change MAXDOP or THRESHOULD ?
No.
0
Eprs_AdminSystem ArchitectAuthor Commented:
But I have to do something.
Always I have PARALLELISM WAITS, sometimes over 20 waits.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
Did you try to run the query without the MAXDOP option?
0
Eprs_AdminSystem ArchitectAuthor Commented:
I cannot change anything in the query, because it comes from the application.
So MAXDOP is still default on my end = 0.
But I changed the THRESHOULD from 5 to 50.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
The threshold don't make nothing if the query has MAXDOP option set. The threshold is only to say to the engine when he can parallelize the queries. So you set it to 50, means that queries that takes less than 50 seconds won't be parallelized. Hope that is that you want.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eprs_AdminSystem ArchitectAuthor Commented:
What I want is -> no waits.

When the threshould was on 5 I had a lot of waits.
Now I have no waits anymore.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
When the threshould was on 5 I had a lot of waits.
 Now I have no waits anymore.
Means that the engine isn't parallelize the query so it's the same as MAXDOP=1
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.