Mysql batch delete lock table solution?

some table in mysql, constantly inserting new data. But to prevent it from getting bigger, you need to execute the delete from statement at the same time to delete the old data before a certain point in time.

now the problem is, when deleting, do not dare to delete too many pieces of data, otherwise, the more you delete, the longer the table will be locked.
can only be deleted more than 100 entries. However, this speed is much less than the number of inserts.

ask, is there any way to make the same table of mysql allow both delete and insert, and keep the total at a certain level of balance. It is mainly the problem of delete locking the table.

Feb.23,2022

you can delete each entry in the program or by using the function/ stored procedure, and the total number of entries will remain the same

.
  

do you have a good solution?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8d130-1129.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8d130-1129.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?