I'm using Spring-data-jpa with CrudRepository to persist data in a postgres db.
On a daily basis I want to renew the full db content, which means detele all data in a specific table first.
The repository offers a method dao.deleteAll(), but that lasts very long as I have about 500k entries.
How can I improve this?
You can execute native sql query on entity manager, and truncate your database
String sql = "TRUNCATE tbl_name;";
entityManager.createNativeQuery(sql).executeUpdate();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With