Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

Purging old Data - 500M+


There are 500million+ records in Test table, how to cleanup old data which are before 5years? It is badly affecting the performance and creating DB LOCK multiple times a day. can you guys share the sql query for it?


Hi Arvind,

If you need to purge large amounts of old data from your TestRail instance, you would be able to automate the deletion of test runs and plans through the API by utilizing the get_runs and get_plans methods along with a filter (such as created_before) to retrieve a list of old test run or plan IDs. Then, you can use delete_run or delete_plan for these runs and plans which you not longer need.

If you need additional details about these API methods, you can review this information here:

I hope this helps and please let me know in case you have any further questions!


Being millions of records api based approach fails to handle it. Dont we have a suggested SQL based methods to remove the records from database. Can you provide the SQL query for it.


Hi Arvind,

Thanks for the reply! We wouldn’t provide SQL queries for this as the API would be the recommended method for safely managing TestRail data, even when deleting entities. Directly modifying TestRail’s database would not be supported at this time.

Please feel free to email us at with additional details about your system, any error messages you receive, etc. and we’ll be glad to assist with this further.