 |
SQL Server 2005 General discussion of SQL Server *2005* version only. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

March 27th, 2008, 11:24 PM
|
Authorized User
|
|
Join Date: Apr 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
View returns huge data,taking more time
Hi,
I have a view which returns around thirty Lakh records. And is taking more time to execute.
The View has around 11 tables in which some of the tables are left joined .. which is resulting in a huge data .....
Is there any way i can make the execution faster?
Kindly help.
Thanks.
Gunjan
__________________
Gunjan
|

March 28th, 2008, 08:10 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
What is "Lakh"?
Have you optimized the table with indexes? Do they all need to be joined with LEFT joins? Is all the data you are getting the data you actually want?
-Peter
peterlanoie.blog
|

March 28th, 2008, 06:46 PM
|
Friend of Wrox
|
|
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
|
|
Lakh = million
--Jeff Moden
|

March 28th, 2008, 06:47 PM
|
Friend of Wrox
|
|
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
|
|
Quote:
quote:Originally posted by gunjan.sh
Hi,
I have a view which returns around thirty Lakh records. And is taking more time to execute.
The View has around 11 tables in which some of the tables are left joined .. which is resulting in a huge data .....
Is there any way i can make the execution faster?
Kindly help.
Thanks.
Gunjan
|
Indexes may help but only if the query in the view is "sargeable". Post the code.
--Jeff Moden
|

March 30th, 2008, 05:44 AM
|
Authorized User
|
|
Join Date: Apr 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
I need all the data returned by doing left joins ...
And have sufficient indexes on the base Tables ...
But still it's getting timed out because of the huge data returned.
Thanks.
Gunjan
|

March 30th, 2008, 11:52 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Then I'm not sure you'll be able to get more out of it. Have you profiled and tested your query to see if there is something in there that could be optimized?
-Peter
peterlanoie.blog
|

March 31st, 2008, 11:24 PM
|
Authorized User
|
|
Join Date: Apr 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I did run the profiler ... but that also was of no help ....
Gunjan
|

April 1st, 2008, 04:15 AM
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You may have a couple of options
1. Do you need all the data at once? If not, divide the data into multiple chunks and receive them one by one. One possible option (I don't know your data but making a wild guess) is breaking the data based on the year (or month if you have only one year's data) or year and month. You may execute the query for every month. To do this in a few you need to add a temp table with only one row having the start date and end date You can loop through to get the whole data
2. Increase query timeout. You can sent it to 0 and the application will wait until SQL Server responds
G.R.Preethiviraj Kulasingham
|

April 1st, 2008, 05:02 AM
|
Authorized User
|
|
Join Date: Apr 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Can u please tell me how to increase the time out period ?
Thanks in advance.
Gunjan
|

April 1st, 2008, 06:48 AM
|
Friend of Wrox
|
|
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
|
|
Increasing the time out period is, at best, a short term patch... not a fix. You'll probably find the real problem in the code in the view... the view probably needs to be rewritten but no one can tell because the code for the view has not been posted.
--Jeff Moden
|
|
 |