After even further analysis, it turns out that using or not using ON DELETE CASCADE isn't the thing that really affects the time it takes to delete the data. The speed-up is gained by using 3 separate statements to delete rows from child tables first followed by the parent table. The same speed-up is present when ON DELETE CASCADE rules are
A couple of days ago I debugged a performance issue that was coming up when trying to remove rows from tables in a PostgreSQL database. There were three tables involved: