Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SQL Query taking long time

Author  Topic 

best_boy26
Starting Member

42 Posts

Posted - 2011-03-19 : 10:00:09
I have a SQL Table.

And I have written againest of it lot of math Calculations and for each calculations I created views and finally I joined all these views as single view.

When I run this final view which has internally about 10 views and taking lot of time and not getting output. I can see my CPU time is taking 100%.

below are my quetions here!!!!!!!

1) Now can anyone explain me the best way of getting the data without disturbing the database performance?

2) Looking for the SQL database performance on when we write the SQL queries.

3) If I change these all quires to run from SQL Reporting services, then SQL query will run without any issues?

4) Experts talks about indexing will indexing concept will do any favor for me since I have only one sql table?

Thanks
JJ

SeanL
Starting Member

3 Posts

Posted - 2011-03-22 : 09:09:58
you have a few options here:
1. Modify your views - create an indexed view. This should improve your performance. By default, a view is not indexed, so if it is relatively large, then the indexing will definately help. see: http://msdn.microsoft.com/en-us/library/aa933148(v=sql.80).aspx for more info.
2. You could drop the views and use derived tables in your query.
Go to Top of Page

Kinnerton
Starting Member

21 Posts

Posted - 2011-03-22 : 10:46:16
I'm with SeanL on this.

Either flatten out your query into a single query and slap a covering index over it. Or break it up into temporary tables - which can make a complicated task significantly easier to manage.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-03-22 : 13:27:07
I know it may be a lot, but why not post the DDL?

Are your underlying tables indexed properly?

What predicates do you use when you execute the view...or are you return 35 million rows?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

best_boy26
Starting Member

42 Posts

Posted - 2011-03-22 : 17:05:28
Thanks All.. on this support.. I am planing to test this by creating index, Yes the data i have about a million rows from one table
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-03-22 : 20:52:36
yes but how much data are you returning?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

best_boy26
Starting Member

42 Posts

Posted - 2011-03-23 : 00:39:20
Around one million.. do you also suggest to use SQL Reporting services to get the data fast?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-03-23 : 01:44:48
my guess is thats the problem..who is gonna look at a million row report

Your buffers, network traffic, etc are all gonna make it slow


WHY do you need a million rows?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -