In mysql, DELETE FROM table
is much more expensive than TRUNCATE TABLE table
I believe that JPA's Entity.deleteAll()
runs delete. What's the correct way to truncate instead?
TRUNCATE TABLE table
is not standard-SQL, so not generally supported. To do it, execute the query directly:
em().createNativeQuery("truncate table MyTable").executeUpdate();
While in a Play Model class (where you have access to the EntityManager
with em()
.
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