Execution time

Last post 02-19-2008 8:03 PM by soeethiha. 4 replies.

Sort Posts:

  • Execution time

    01-10-2008, 2:10 AM
    • Member
      95 point Member
    • soeethiha
    • Member since 12-05-2007, 3:44 AM
    • Singapore
    • Posts 22

    Hello Anybody !

    I want to get the execution time of a query, I mean I will run the one sql statement like this " SELECT * FROM tblname WHERE field1 = '009' and then I want to get from my program execution time of this query. I think I just keep the sys time before run it and compare with sys time when finished it. But I don't like this one, So, can I get the execution time from sql server by running their sys s-procedure or something like.

     Thanks.

     

    Soee Thiha
  • Re: Execution time

    01-10-2008, 3:16 AM

    Hi,

    You can get your querry execution plan by addin following this from SqlServer Management Studio Meues.

    Go to Querry menu and add following things.

    1.Display Estimated Execution Plan

    2.Include Actual Execution Plan.

    From this technique you can also optimise your queryy,like creating nonclustered indexes,statistics and database partitioning etc.

    Mark answered if this post help you.

     

     

  • Re: Execution time

    01-10-2008, 3:45 AM
    • Member
      95 point Member
    • soeethiha
    • Member since 12-05-2007, 3:44 AM
    • Singapore
    • Posts 22

    Thanks for your help. But this one I already, I mean I want to get from my program of executing time of query.

    My logic is like this. some thing like ths search engine. I would to search the inventory part id in my database, If found, I want to display the search time for it to the user. So I need to get the execution time from my program.

    Thanks.

    Soee Thiha
  • Re: Execution time

    02-19-2008, 9:37 AM
    Answer
    • Participant
      796 point Participant
    • aspdotnetjunkie
    • Member since 12-18-2006, 7:37 PM
    • Shelton, CT
    • Posts 220

     " /* Read the initial time. */
        DateTime startTime = DateTime.Now;
        Console.WriteLine(startTime);

        /* YOUR QUERY. */
        

        /* Read the end time. */
        DateTime stopTime = DateTime.Now;
        Console.WriteLine(stopTime);

        /* Compute the duration between the initial and the end time. */
        TimeSpan duration = stopTime - startTime;
        Console.WriteLine(duration);

    The output of this code looks something like this:

    
        4/17/2005 4:12:30 PM
        4/17/2005 4:12:31 PM
        00:00:01.7224768"
    
    Don't forget to "Mark as Answer" if this post answered your question
    Life's good
    My Site
  • Re: Execution time

    02-19-2008, 8:03 PM
    • Member
      95 point Member
    • soeethiha
    • Member since 12-05-2007, 3:44 AM
    • Singapore
    • Posts 22

    Yes junkie... Thanks a lot for your answer.

    Soee Thiha
Page 1 of 1 (5 items)