UNION ALL Optimization

  • select Colum1 , Colum2  from  table 1

    Union All

    select Colum1 , Colum2  from  table 2

    Union All

    select Colum1 , Colum2  from  table 3

    How to Optimize above 3 Queries into one.

  • Combining them wouldn't optimize it.  For three different tables, SQL must still scan each table/covering index to provide the results.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • ralahari wrote:

    How to Optimize above 3 Queries into one.

    It already is one query.

  • I am looking for With out Union all how to achieve same Query o/p. Any helps highly Appreciated.

  • ralahari wrote:

    I am looking for With out Union all how to achieve same Query o/p. Any helps highly Appreciated.

    Why would you want to do it without a union and in just one query?

  • .

    • This reply was modified 6 months, 1 week ago by  Jonathan AC Roberts. Reason: deleted duplicate post
  • @ralahari:

    Paste your query and execution plan with data if possible. Understand that, there are many variables that we need to look into to optimize a query

    =======================================================================

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

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