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
 General SQL Server Forums
 New to SQL Server Programming
 Nominal time for complex Select Query

Author  Topic 

ramyaraman
Starting Member

10 Posts

Posted - 2008-06-30 : 10:28:01
I have several complex select queries which selects from 2-3 tables, with 3-4 inner,right outer joins, and also 5 functions that are being called from that select query for almost 200000 rows.

The total rows that get return is 2 million. Currently my query takes 50 minutes to return this. Is this normal? What should be the average time to return 2 million row on a decent server

I believe it is taking too much time. Having index is not improving perfomance.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-06-30 : 10:32:21
Did you see execution plan if anything is costly?
Go to Top of Page

ramyaraman
Starting Member

10 Posts

Posted - 2008-06-30 : 10:34:35
I don't see anything costly on execution plan. It is using my indexes.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-30 : 10:40:12
quote:
Originally posted by ramyaraman

I don't see anything costly on execution plan. It is using my indexes.


is it using index scans or seeks? also what are other steps involved? probably you could concentrate on steps which has greater % of query cost?
Go to Top of Page

ramyaraman
Starting Member

10 Posts

Posted - 2008-06-30 : 10:49:52
I do see it is doing Index Seeks. Also it uses Lazy Spool.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-30 : 10:52:19
quote:
Originally posted by ramyaraman

I do see it is doing Index Seeks. Also it uses Lazy Spool.


which is the costliest step?
Go to Top of Page

ramyaraman
Starting Member

10 Posts

Posted - 2008-06-30 : 11:04:51
Index Seek for a clustered index cost me 48%
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-30 : 11:11:38
quote:
Originally posted by ramyaraman

Index Seek for a clustered index cost me 48%


sorry apart from seeks is there anything taking significant cost?
Go to Top of Page

ramyaraman
Starting Member

10 Posts

Posted - 2008-06-30 : 11:30:07
I have two sorts that takes up 20%,25% and 1 Table spoll/eager spool 13%
Go to Top of Page

maninder
Posting Yak Master

100 Posts

Posted - 2008-06-30 : 11:30:10
What are your Server Specs.
Version/Edition(Developer/Standard/ENT)
HArdware Specs? (Processor/Memory)
Are all these tables in one Database?Any Table partition?


Maninder
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-30 : 11:33:54
quote:
Originally posted by ramyaraman

I have two sorts that takes up 20%,25% and 1 Table spoll/eager spool 13%


Sort can be a costly operation. Have you analysed the cause of these sorts?
Go to Top of Page

ramyaraman
Starting Member

10 Posts

Posted - 2008-06-30 : 11:36:29
This is sql2000 Enterprise Edition on windows 2003 Standard edition
It has 4GB of RAM and AMD Athlon 64*2 Dual Core Processsor 3800+ 2.01 GHZ
On the same db with no table partition
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-06-30 : 11:58:50
Can you put that query in Database Tuning Advisor and see Improvement Percentages? Do it in your machine ?
Go to Top of Page

ramyaraman
Starting Member

10 Posts

Posted - 2008-06-30 : 12:02:13
I did use index tuning wizard and no recommendations
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-06-30 : 13:38:57
quote:
Originally posted by ramyaraman

I have two sorts that takes up 20%,25% and 1 Table spoll/eager spool 13%



It means it has to create Temp table for it . Is your TempDB optimized and also Indexes and stats optimized?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-30 : 13:43:17
quote:
Originally posted by ramyaraman


The total rows that get return is 2 million. Currently my query takes 50 minutes to return this. Is this normal? What should be the average time to return 2 million row on a decent server



You will never be able to return 2 million rows quickly (measuring in seconds at least). Why do you need to return so much data? No human can process that much data. Is the data being fed into another system? Could you explain your process?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -