I am trying to perform cascading deletion in the database but because the records are many and the deletion is happening in many tables, this takes a long and the database gets disconnected after a while. How to solve this?

Question
I am trying to perform cascading deletion in the database but because the records are many and the deletion is happening in many tables, this takes a long and the database gets disconnected after a while. How to solve this?
