Calculating Transaction Concurrency from a DB table

A customer I was doing some performance testing for wanted to know how many particular transactions where being processed at any one time. Within their DB they capture the start time and end time of the transaction. So, I thought I could give them an indication of concurrency if I could construct a SQL query to extract and process the data.

Here is a a example that I have constructed in a simple MySQL DB (rather than use their data). For this purpose a table called log containing start and end time.


Here is the code I wrote. Any optimisation to the SQL welcome. (I am but a performance tester interested in the data)

SELECT tL.StartTime, (select count(1) from test.Log where StartTime = tL.StartTime) FROM test.Log tL where StartTime > 0 group by StartTime order by 1

Here is the output from running the query. It should be noted that it presents the concurrency at the start time of a new transaction.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s