which one is fast???

Last post 01-03-2009 6:20 AM by RickNZ. 3 replies.

Sort Posts:

  • which one is fast???

    01-02-2009, 5:11 AM
    • Member
      142 point Member
    • ramesh.rathi
    • Member since 05-14-2008, 11:46 AM
    • India
    • Posts 214

    hi all,

    which sql query will be fast when run on the server..i am using sql query to get the data from the database and bind the data to the gridview.

     

    Query1: select * from table

    Query2: select * from table for xml raw

    Query3: select * from table for xml auto.

     

    Thanks in adance,

    Ramesh Rathi.

  • Re: which one is fast???

    01-02-2009, 6:07 AM
    Answer
    • All-Star
      21,236 point All-Star
    • raghav_khunger
    • Member since 08-18-2008, 8:25 AM
    • Delhi, India
    • Posts 3,776
    • TrustedFriends-MVPs

    Hi,

     

    U can Get Ur Answer from

    Set ShowPlan_All on

    GO

    select * from [table]

    select * from [table] for xml raw

    select * from [table] for xml auto

    GO

     

    Or U can Check That Each By Running Sql profiler

     

    TOols>>Sql Profiler

     

    Raghav CodeASP.NET Community | My Blog | jQuery Intellisense in Visual Studio 2008




    "Success doesn't come to you…you go to it."--Marva Collins

    "Failure is success if we learn from it." Malcolm Forbes

    "Success does not come to those who wait . . . and it does not wait for anyone to come to it." Anonymous


  • Re: which one is fast???

    01-02-2009, 7:16 AM
    Answer
    • Star
      8,825 point Star
    • ksridharbabuus
    • Member since 11-10-2007, 1:02 PM
    • Bangalore, India
    • Posts 1,294

     Hi,

      You can use Execution Plan to identify which is faster.

    Please note that this queries will be used depending on the how you are going to utilize the output with in your front-end application.

    Between XML Raw and XML Auto the different is only the xml structure, remaining behavior is same with both the clauses.

     

    -Sri
    Visit My Blog
    -------------------------------------------------
    If this post was useful to you, please mark it as answer. Thank you!
  • Re: which one is fast???

    01-03-2009, 6:20 AM
    Answer
    • Contributor
      5,230 point Contributor
    • RickNZ
    • Member since 01-01-2009, 3:43 AM
    • Nelson, New Zealand
    • Posts 874

    It will be faster if the data doesn't have to be converted to XML -- so query1 is best.  It returns a row set, which can be easily and efficiently bound to a gridview.

     

Page 1 of 1 (4 items)