-1

Hi everyone I am hoping for some help/insight/ideas on how to best select data from my tables(I can do inner joins but that's about as "complicated" as my knowledge goes with SQL). Well I'm using this query but it takes 4 hours

SELECT   FROM 
(
 SELECT  FROM 
 (
SELECT    FROM        )AS 
 )
 AS ....
(SELECT     ...FROM         ...  )AS...,
(SELECT     .....FROM         ...   )
AS ...
(SELECT     ........FROM         ....)   AS ....
(SELECT....FROM         ....  )AS ...
(SELECT     ...FROM         ....  )AS ...,
(SELECT    .....FROM         .....   )AS [.....
( SELECT    .....FROM         .....   )AS [.....
(SELECT    .....FROM         .....   ) AS [.....
(SELECT    .....FROM         .....   )   AS [.....
(SELECT    .....FROM         .....   )   AS [.....
WHERE 
(
And (
And ....
0

1 Answer 1

1

Generally, JOINs tend to be faster than nested SELECTs so see if you can recast the query to use them.

An alternative approach is to have a look at the execution plan for your query, see which part takes longest and try and speed up that part. You'll hugely broaden your understanding of SQL in doing this, so even if it only takes the execution time down to 3h 55m you will gain a lot from it.

1
  • Thank you for answering my question. At the EP "clustred index scan" takes longest
    – unknown
    Commented Jun 6, 2013 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.