?
Solved

SQL Performance issue

Posted on 2013-05-11
7
Medium Priority
?
325 Views
Last Modified: 2013-05-15
I have 2 environment say A &  B. A  is the testing phrase 1 environment and B is testing phrase 2 env.

In A env I have database which holds more data than env B. When I run a select query on Env A it get's executed fast(say 40 seconds.)Same query executing on env B takes 50 minutes.

Result of this query doesn't return any records.It will be 0.
The select query has 15 joins.No aggregation/calculation is performed in this query. It's just selecting a columns.

1.Below are my analysis details:
I saw the execution plan on both ENV.
In A estimated number & actual number of rows is 0 
In B estimated number = ~76 millions & actual number of rows is 0 

2.Fragmentation:
In env a= ~0.99 for all 15 tables
In env b = ~ 14 for all 15 tables

3.Same query executing without where clause in B is taking just 1 minute.

Should I update the statistics? 

Open in new window

0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 23

Accepted Solution

by:
Racim BOUDJAKDJI earned 2000 total points
ID: 39158379
Please post the show plan.  It looks you are missing an index.  Posting the query would help.  updating statistics and index rebuild can not hurt.  Just make sure you do it at the right time.
0
 
LVL 5

Author Comment

by:VIVEKANANDHAN_PERIASAMY
ID: 39158410
Sorry,Right now I in home and couldn't help to post the plan.

But I confirm that,both has same indexes I missed to mention this point while posting.

Just trying to understand why estimated rows is high for env B.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39158770
Just trying to understand why estimated rows is high for env B.
When was the last time statistics were updated?
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 12

Expert Comment

by:Saurabh Bhadauria
ID: 39158947
Two things you can try to updating your statistics ..
Another optimize your query , it may help as the same can behave differently in different environment as per data volume...
And chk out your indexes...
0
 
LVL 5

Author Comment

by:VIVEKANANDHAN_PERIASAMY
ID: 39159086
My concerns here, env having large number of records executes fast ( less than minute) and environment having less records taking long time (morethan 50 minutes). Both output are the same,both have same number of indexes.

I have just like know why the estimated number of records is high(~75 million) in one and 0 in another.So like to understand what is happening inside the database engine.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 39159656
I have just like know why the estimated number of records is high(~75 million) in one and 0 in another.
Let's try that again, as you may have overlooked my comment:
When was the last time statistics were updated?

Let me know if you do not understand the relevance of the question and why it may address your specific question.
0
 
LVL 5

Author Comment

by:VIVEKANANDHAN_PERIASAMY
ID: 39163715
>>Should I update the statistics? <<

Running sp_updatestats fixed the issue.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Suggested Courses

762 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