October 28, 2009 at 11:52 am
TheSQLGuru (10/28/2009)
I would think that doing 4 table scans and 4 joins on a table with 40M rows WILL take some time. 🙂
I thought 40 Lakh = 4 Million ?
Anyway either way it is still not going to run fast with all those unions and joins
October 28, 2009 at 12:32 pm
steveb. (10/26/2009)
You will need the correct indexes to speed up the query.Can you post the table and index structure as well as your query and execution plan?
We're still waiting on your indexing information and execution plan details.
October 28, 2009 at 12:40 pm
Hi John iam attaching execution plan pls go through it.
October 28, 2009 at 1:31 pm
October 28, 2009 at 1:47 pm
There really was no need for indexing information or the query plan. 🙂 The query as written clearly was doing 4 table scans and 4 associated joins. Even with covering indexes this is going to be suboptimal. I believe there is a way to rewrite the query to be single pass. I presented one possible method and there are two other potentially viable mechanisms I can think of if the first (and simplest) doesn't work.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
October 28, 2009 at 2:38 pm
October 28, 2009 at 11:09 pm
Hi Sql Guru I tried with example which u gave but it is much time than what i already had can u give me those two possible
solutions
October 29, 2009 at 9:05 am
mssdprasad04 (10/28/2009)
Hi Sql Guru I tried with example which u gave but it is much time than what i already had can u give me those two possiblesolutions
I am swamped today so I won't be able to get to it until tomorrow.
In the mean time, please give us the query plan for my first attempt. Also please attach the output you get from SET STATISTICS IO ON from your original query and my version.
Oh, and does mine give equal output as yours?
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
Viewing 8 posts - 16 through 23 (of 23 total)
You must be logged in to reply to this topic. Login to reply