Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 212117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:09:27+00:00 2026-05-11T18:09:27+00:00

Summary I am after some advice on the easiest way to analyze simple data

  • 0

Summary

I am after some advice on the easiest way to analyze simple data using SQL server and .net

Details

Really simple data – just need really simple way to analyze (with my simple brain)

I have a SQL Server table:

  • PKID (Int)
  • ApplicationName (VarChar)
  • MethodName (VarChar)
  • TimeInMs (Integer)
  • AdditionalInfo (VarChar)
  • DateTime (DateTime)

This table records the length of time it took for various methods to run in various applications. This table could potentially have tens of thousands of rows. I would like to easily extract useful info from this (some of it in real time). I am not sure of the best way to go about this. This kind of data I would like is:

Data
– Average length of time for method call
– Top ten slowest method calls
– Top ten fastest method calls

For the periods of:
– last min, hour, day, week, month
– each day for the last 7 days, each week for the last 10 weeks

For the applications:
– All
– Each individually

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:09:27+00:00Added an answer on May 11, 2026 at 6:09 pm

    I think ojblass was refering to the DataTime field you omitted from your question.

    The actual timestamp datatype in MS SQL Server is misleading in name. It has nothing to do with dates and times. It is a binary “version number”. It is used mostly to deal with concurrency issues when updating a row in the table but would be useless for any analysis tasks.

    I would suggest improving your column names a bit. Calling a column “DateTime” is confusing and could cause you some trouble in writing queries if you aren’t careful.

    Anyway… the queries you are looking for range from simple to quite complex if written directly in TSQL.

    Here are some examples (I have not syntax checked these, so they are “approximate” at best):

    Average time for a specific method

    select avg(TimeInMs) as AvgTime from Table 
    where ApplicaitonName = @ApplicationName
    

    Average time for a specific method during the last 1 minute

    select avg(TimeInMs) as AvgTime from Table 
    where ApplicaitonName = @ApplicationName and 
        [DateTime] >= DATEADD(minute, -1, getdate())
    

    You’ll end up wanting to write stored procedures for most of these. Some of the queries you talk about will require some grouping and such too… I recommend you get a book on TSQL if you go this route.

    If you are doing this with LINQ to SQL within your applicaiton, it isn’t much different, but in general LINQ is easier to write (debatable of course).

    Here are the same two queries using LINQ to SQL in C# (again, I haven’t tested these, so I could be minor syntax mistakes).

    var ctx = new MyDataContext();
    var q = (from item in ctx.Table
            where item.ApplicationName == "MyApplication"
            select item.TimeInMs).Average();
    
    
    var ctx = new MyDataContext();
    var q = (from item in ctx.Table
            where item.ApplicationName == "MyApplication" &&
                  item.DateTime <= DateTime.Now.AddMinutes(-1)
            select new item.TimeInMs).Average();
    

    How you do the analysis depends on what technologies you are using and what you are doing with the results.

    Update:
    In answer to follow-up question from comments:

    I can’t think of a good way to handle it via storing the desired time intervals in another table that doesn’t get massivly difficult (cursors and dynamically constructed TSQL via the Execture command).

    A simpler query that gets the results you want might look like this in TSQL (I’m not advocating that this is the “best” way, but it works and is pretty fast).

    select avg(TimeInMs) as AvgTime, 'Last 1 minute' as TimePeriod from Table 
    where ApplicaitonName = @ApplicationName and 
        [DateTime] >= DATEADD(minute, -1, getdate())
    union
    select avg(TimeInMs) as AvgTime, 'Last 2 minutes' as TimePeriod from Table 
    where ApplicaitonName = @ApplicationName and 
        [DateTime] >= DATEADD(minute, -2, getdate())
    -- //repeat union as many times as needed for each time period
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an easy way to get a conflict summary after running a cvs
SUMMARY: When browsing an ASP.NET website using Windows Explorer, popup windows do not borrow
Summary What's the best way to ensure a table cell cannot be less than
Summary: I'm able to compile a RAD Studio 2009 project using MSBuild on a
What references offer a good summary/tutorial for using RDF/OWL? There seem to be enough
Occasionally I commit some code to the repository, add a comment/summary, then read the
I need to read some filenames from an xml config file using xmlstarlet with
I have a validation Summary I am using for the RequiredFieldValidators to use to
Summary Hi All, OK, further into my adventures with custom controls... In summary, here
Summary: I'm developing a persistent Java web application, and I need to make sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.