Could you please check at DB level out of box stored procedure exists??
We faced similar latency issue in our environment but we are using Oracle DB. If you confirm I can share a Java utility which you have to configure for cronjob script call. This will make connection against DB and clean the persistent DB using store procedure.
Thanks! Alok