Hi Sergey,
Thanks for your reply! The test cases are duplicated in the background when closing a test run/plan to create an immutable version of the test case (so that changes/moves/deletes to a test case don’t affect the history of the test when it was run on any specific run/plan). This would store these in the database and increase the IDs as needed, and this is the standard behavior of TestRail. TestRail would just require that the IDs be unique in the database.
TestRail’s database was designed to scale well, and please note that you should never directly write to or change anything in TestRail’s database. This would break the consistency of the database, even small changes you might find unproblematic, and your TestRail instance would be immediately unsupported. You wouldn’t be able to upgrade anymore and we wouldn’t be able to support the instance anymore. So you shouldn’t attempt to clean the table directly in the database. The only method to clear this would be to delete the closed/archived runs/plans directly via the UI, however this is only recommend if you actually want to remove the history of the full test run/plan indefinitely (as this cannot be undone).
Hope this helps!
Regards,
Marco