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
Solved

SQL Queries are getting slower

Posted on 2003-12-05
14
297 Views
Last Modified: 2012-05-04
I have a survey site that allows people to sign up for an account and create their own surveys and collect data on my server.

Before I had any customers, the speed of retrieving survey data was very fast.  But, it is becoming progressively slower to retrieve data the more customer accounts there are.  Many accounts have surveys with 20 or 30 questions and with 100+ responses.

I even did a parallel test with the same survey and retrieved survey data from one database that had just one customer account and then one from my current database with 1000+ customer accounts.  In some cases it took 3 minutes on the larger database to pull survey data that could be pulled in just a few seconds with the smaller database.

First of all, why is this happening?  Second of all, I want to determine how to optimize my site (which is written in .net (.aspx) and uses sql 2000 so it will run just as fast with a thousand accounts as it would with one account.

Any thoughts on what could be going on and what I could do to fix this? Thanks.

Andrew
0
Comment
Question by:gator93
  • 8
  • 6
14 Comments
 
LVL 9

Expert Comment

by:PaulBarbin
ID: 9885772
Do you have indexes setup?  
What does the select statement look like?
Have you checked the execution plans?

Paul
0
 

Author Comment

by:gator93
ID: 9885820
Right now I have clustered indexes on the primary key for each table, but that's it.  We are possibly planning to use an index tuning wizard to create non clustered indexes for the tables.  Does that make sense to do that?  Would that increase the performance a lot to do this?

An example of a select statement that we are using is:

select * from survey where ib = 100

What do you mean by check the execution plans?  Can you be more specific.

Thanks.
0
 
LVL 9

Expert Comment

by:PaulBarbin
ID: 9885833
I didn't realize that the queries were that straightforward.  I was asking you to press Ctrl+L (or Ctrl+K) in Query Analyzer to view the execution plan to see if you could determine the difference.  But that's not likely going to help us here.

Is "ib" the column that the clustered index is on?  I am guessing its not.

Paul
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 9

Expert Comment

by:PaulBarbin
ID: 9885839
Also, are you joining on the customer table?

0
 

Author Comment

by:gator93
ID: 9885866

Thats how the majority of the queries are.  There are only a couple of Join queries but none on the customers table.

All tables have a ID, and that is the Primary Id.
0
 
LVL 9

Expert Comment

by:PaulBarbin
ID: 9885877
Give me the entire query that you're running that takes 3 minutes.  Explain the tables involved and give me rough idea on the number of rows in each.

0
 

Author Comment

by:gator93
ID: 9885896
Its not just one query.  Its one page that is doing several queries and the page takes 3 min to come up when it used to take about 20 seconds.
0
 
LVL 9

Expert Comment

by:PaulBarbin
ID: 9885897
Wait, if you don't have ANY nonclustered indexes and you're joining tables, then the problem is likely that you need nonclustered indexes on the foreign key fields.  The execution plan in Query Analyzer would show that.  

Paul
0
 

Author Comment

by:gator93
ID: 9885922
If I run a trace and put that log into the Index Tuning Wizard.  Would it tell me all the nonclustered indexes I should create.
0
 
LVL 9

Expert Comment

by:PaulBarbin
ID: 9885933
I guarantee that if you don't have nonclustered indexes and you are doing joins, that's your problem.  Lets test it and see.  If it doesn't work, then just take them back out.

Paul
0
 

Author Comment

by:gator93
ID: 9885942
But I am only using Joins a couple of times on the whole site.
0
 
LVL 9

Accepted Solution

by:
PaulBarbin earned 500 total points
ID: 9885963
We could go on like this forever!  Either post the queries that you are using joins on, or just create nonclustered indexes for all foreign keys for tables where you are joining using that column.  I can tell you that this will very likely have a significant impact on the query time!

P.S.  I am leaving soon and might not be able to check this post again tonite.  Can you just try one for me quickly?

Paul
0
 

Author Comment

by:gator93
ID: 9885976
Ill create nonclustered indexes on all my foreign keys.

Thanks Paul
0
 
LVL 9

Expert Comment

by:PaulBarbin
ID: 9885981
Good luck.  If it doesn't work, post back and we'll take it step by step.

Paul
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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…
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.
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.

829 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