subquery's optimisation

  • Hi , I need some help to kno how can optimize the follow queries ?

    SELECTpc.Name

    ,ppsc.Name

    , (SELECT COUNT(*) FROM Production.Product pp

    WHERE pp.ProductSubcategoryID = ppsc.ProductSubcategoryID) as NumberOfProducts

    FROMProduction.ProductCategory pc

    INNER JOINProduction.ProductSubCategory ppsc

    ONpc.ProductcategoryID = ppsc.ProductcategoryID

    AND

    SELECTpw.ProductID

    , pp.Name

    , ppsc.Name

    , SUM(pw.OrderQty) as Quantity

    FROMProduction.Product pp

    LEFT JOINProduction.ProductSubCategory ppsc

    ONpp.ProductSubcategoryID = ppsc.ProductSubcategoryID

    INNER JOINProduction.WorkOrder pw

    ONpw.ProductID = pp.ProductID

    WHERE pw.DueDate = '2003-06-03 00:00:00.000'

    GROUP BY pw.ProductID, pp.Name, ppsc.Name

  • Table definitions, index definitions and execution plan (as a .sqlplan file) please.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Hi,

    Thanks a lot of your assware. But you are ask me for that information?

  • http://sqlblog.com/blogs/rob_farley/archive/2011/04/13/the-power-of-t-sql-s-apply-operator.aspx

    Catch-all queries done right [/url]
    Gail Shaw's Performance Blog[/url]

  • pedro.j.manuel (11/30/2015)


    Hi,

    Thanks a lot of your assware. But you are ask me for that information?

    Assware?



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • It was answer...

  • Yes, I am asking you for that information. We can't help you tune a query just by seeing the T-SQL of it.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Hi,

    You can use the query in Adventureworks2012.

    Thanks,

    Pedro

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply