Solved

SQL Query runs slow for specific user, fast for another user.

Posted on 2012-04-05
9
859 Views
Last Modified: 2012-07-05
Our company sells a product that uses a MS SQL Server backend. Our product contains a tool that runs a query to extract billing information. Two users run this tool remotely on a terminal server. One user can run the tool and the results are returned in less than a minute. When the other user runs the same tool the query can take up to five minutes. Testing with the same query criteria by either user's account with sequential non-concurrent logins yields the same delay for this one specific user. The only difference in their account profiles is that the account that gets a fast response is a member of domain admins and the account that gets a slow response is a standard domain user. This is for one particular client running SQL Server 2008 R2 which is hosted on a dedicated server. The demand load on the SQL server is low to moderate the majority of the time. Testing with both accounts using RDP from the same computer or different computers at different locations produces the same results. I suspect the problem is with the SQL backend and possibly involves authentication. The SQL Server is set to use Windows Authentication and connection is via TCP/IP.
0
Comment
Question by:jtforde518
  • 3
  • 3
  • 3
9 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
ID: 37814786
How many rows are returned in each case?
Are the two users logging on to the same terminal?
0
 
LVL 45

Assisted Solution

by:Kent Olsen
Kent Olsen earned 250 total points
ID: 37814799
Lots of questions....

- Are both users running the exact same query?
- What are the differences?  (Account number perhaps?)
- Do both queries generate the same explain plan?
- How many rows are returned for each query?
- Can the timings that you're seeing be repeated from other locations?  (Can you run both queries from your desktop?)
- Are the tables properly indexed?
- Are the index nodes balanced?  (Has there been a lot of insert/delete activity since the index was created?)
- How long have the two accounts existed on the system?
- How many rows in the "big" table are there for each account?
- Are any of the tables partitioned?

Let's start here and move forward...  :)


Kent
0
 

Author Comment

by:jtforde518
ID: 37834078
both users are using the same custom tool which runs the query. The same person is running the exact same query with the same criteria. The same data is returned. The problem is the time it takes "User B" to run the tool is almost 5 minutes while "User A" runs it and it completes in less than a minute. This occurs regardless of what computer the person tests from.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 45

Expert Comment

by:Kent Olsen
ID: 37834142
Would still like some more detail on your database, and explain plans from both users.    :)



Do either of these two users own any/all of the objects being queried?  Are views being used over the data?

What I'm looking for is a condition where there is a table that is owned by user A and a view with the same name as User A's table that is used by user B.


user A owns the table masterdata

user B could be accessing *UserA.masterdata* via a view

CREATE VIEW Userb.masterdata AS
SELECT * from Usera.masterdata where name = 'ME';


  SELECT * FROM masterdata WHERE date < current_date - 100;

When UserA runs the query above, the table is accessed directly, using any appropriate index.

When userB runs the query, the index is used to create the subset of rows that is the result of the view.  The result is then scanned via a full table scan to return the rows that have the correct date.  If UserB has a lot of rows, this takes a lot of time.


Kent
0
 

Author Comment

by:jtforde518
ID: 37834816
User A is dbo, User B is normal user with all permissions public.
Same query every time with one user doing the testing logging in with both accounts.
Explain data does not change. Query does not change.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 37835491
Please post the Execution plan in each case.
0
 
LVL 45

Expert Comment

by:Kent Olsen
ID: 37835510
I've got about 10 questions just a few posts up.  Can you answer them?  They really could be relevant.

Thanks,
Kent
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 37835864
And I have just got 2 and I still have not got a clear answer.  :)
0
 

Author Closing Comment

by:jtforde518
ID: 38158081
Thanks for the help. I appreciate all the responses and I'm splitting the points between you. The problem was rendered moot by the implementation of a newer version of a C# .NET custom query reporting tool. The suggestions and the questions helped us pinpoint issues in our application and we modified both the backend and the query tool to correct for the problems we were having.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

828 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