Deleting old load test results


Load testers sometimes need to clean up old load test results from the VSTS load test results store.   The following SQL script deletes all load test results older than two weeks (though the timeframe is easily changed).

If you have a lot of results, this could take a while to run.  I would recommend that you do not run this script while a load test is running as we have seen this cause the load test to timeout while trying to write to the database.

— This script deletes all load test run older than two weeks
— To change the timeframe, change the number of days from 14 to the desired number

USE LoadTest
DECLARE @LoadTestRunId int
DECLARE OldLoadTestsCursor CURSOR FOR
    SELECT LoadTestRunId FROM LoadTestRun WHERE datediff(dd, StartTime, getdate()) > 14

OPEN OldLoadTestsCursor
FETCH NEXT FROM OldLoadTestsCursor INTO @LoadTestRunId

WHILE @@FETCH_STATUS = 0
BEGIN
    EXEC Prc_DeleteLoadTestRun @LoadTestRunId
    FETCH NEXT FROM OldLoadTestsCursor INTO @LoadTestRunId
END

CLOSE OldLoadTestsCursor
DEALLOCATE OldLoadTestsCursor

 


Comments (10)

  1. Rob Caron says:

    There’s been a lot of attention lately on Team Foundation Server as it gets ready to ship. But…

  2. All tasks that should be performed on a regulary basis are listed here.

    Deleting old load test results (via…

  3. All tasks that should be performed on a regulary basis are listed here. Deleting old load test results

  4. eoftedal says:

    Thanks you. Just what I needed.

  5. smtripathi99 says:

    hi,

    it gives error could not locate loadtest database in sysdatabases.

    sneh,

    smtripathi99@hotmail.com

  6. Visual Studio Team System for Testers Content Index for Web Tests and Load Tests Getting Started Online

  7. BennyKusman says:

    IS THE time taken is long ? seems for me it takes forever

  8. DSF says:

    Hi Bill.

    In the 'Open and Manage Load Test Results' window you can select multiple test results for export or removal, but for some reason the option to open them is disabled (VSTS2010 Ultimate).  How can I open multiple load test results then ?