Reducing MSSQL query execution Time

i have this query which has result as paged and cross joined
but the execution time of the query is alarmingly  high ie 15 to 25 seconds
how can I reduce this
please help!!!!!!!!!1

SELECT     TOP 15 THREAD.threadID, COALESCE (POST.postDateTime, THREAD.threadDateTime) AS lastpostDatetime, COALESCE (POST.userID, THREAD.userID)
                      AS lastpostUserID
                      POST ON THREAD.threadID = POST.threadID AND POST.postID IN
                          (SELECT     TOP 1 postid
                            FROM          post postfirst
                            WHERE      postfirst.threadid = thread.threadid
                            ORDER BY postdatetime DESC)
WHERE     (THREAD.forumID = 1) AND (THREAD.threadID NOT IN
                          (SELECT     threadid
                            FROM          (SELECT     TOP 15 A.threadid, COALESCE (B.postDateTime, A.threadDateTime) AS lastpostDatetimeA
                                                    FROM          THREAD A LEFT OUTER JOIN
                                                                           POST B ON A.threadID = B.threadID AND B.postID IN
                                                                               (SELECT     TOP 1 postid
                                                                                 FROM          post postfirstA
                                                                                 WHERE      postfirstA.threadid = A.threadid
                                                                                 ORDER BY postfirstA.postdatetime DESC)
                                                    WHERE      (A.forumID = 1)
                                                    ORDER BY lastpostDatetimeA DESC) DERIVEDTBL))
ORDER BY lastpostDatetime DESC

the first TOP 15 is the pagesize
and the second TOP 15 is the pagesize* (pagenumber-1)

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
Your execution plan shows that, there are a lot of Table Scans. And you uses IN and NOT IN operations.
There are two things sthat you should do,
1. Try to replace the IN and NOT IN operations
2. Also run index tuning wizard for this query, to create proper indexes

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Try to place in VB code
Ex: docmd.runsql " Select ......"
broken sql in two query separatley
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.