SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Sql Server Strange Behaviour
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ilninno
Starting Member

2 Posts

Posted - 08/28/2012 :  15:42:15  Show Profile  Reply with Quote
Hello all,

We are having an strange problem:

We have two servers and two databases (Nearly the same data)

DB1 is running on server 1

DB2 is running on server 2

DB1 executes an sql script in 7 seconds

DB2 executes the same sql script in 600 seconds.

DB2 is copied to Server 1 in order to discard server performance issues, but the sql script run slowly too on this server.

Once is clear that server performance is not the problem, we think that is caused by small data variations:

The Scripts call to a view where it seems to be the problem:

Case 1: We replaced the view invocation for a replica table (same view data) and it works very fast.

Script calls table (equivalent to the view)

Case 2: As a result of this we think that the problem could be inside the view (it calls to smaller views), so we replace the smaller views call for the equivalent tables, but it works slowly.

Script calls View -> View calls tables (equivalent tables to the subviews)

Resume: The problem does not seems to be inside the view, because the Case 2 works slow. It seems that the problem is because we call the view, does it make sense? remember that this view is running fast on the DB1

Transaction logs has been trunked, Index has been rebuild, a DB shrink has been executed.

Thank you!!

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 08/28/2012 :  15:54:27  Show Profile  Visit tkizer's Homepage  Reply with Quote
You need to compare the execution plans. What is different between them? Scan vs. seek? Have you run update stats with fullscan on the tables involved on the problematic database?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 08/28/2012 :  15:55:25  Show Profile  Visit tkizer's Homepage  Reply with Quote
Have you freed the procedure cache on both systems to ensure the same baseline?

And just how much data variation is there?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

chadmat
The Chadinator

USA
1949 Posts

Posted - 08/28/2012 :  17:17:34  Show Profile  Visit chadmat's Homepage  Reply with Quote
Are indexes the same? Are the queries exactly the same (Parameters etc..). Free Data and Proc caches before each execution and compare the query plans as Tara suggested.

-Chad
Go to Top of Page

chadmat
The Chadinator

USA
1949 Posts

Posted - 08/28/2012 :  17:18:12  Show Profile  Visit chadmat's Homepage  Reply with Quote
Also, you can try updateing stats.

-Chad
Go to Top of Page

ilninno
Starting Member

2 Posts

Posted - 08/28/2012 :  17:59:22  Show Profile  Reply with Quote
It was the execution plan, we have cleaned the statistics and the procedure cache and now is working fine.

Thank you very much!!!
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 08/28/2012 :  18:19:45  Show Profile  Visit tkizer's Homepage  Reply with Quote


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000