[Answered ]-Django Bulk Model Deletion with Indices

1👍

These are mysql issues rather than django issues.

Slow Delete.

In any RDBMS, be it mysql or postgresql or anything else, bulk insert, delete and update will always be slow if you have indexes. That’s the nature of the beast.

The best way to speed it up is to examine your indexes and drop any that are not being used in queries. If you want to keep all indexes, optimize the key buffer size.

As a regular user of postgresql, I assure you that this is not reason enough to switch to postgreql from mysql. If you look at the bigger picture and all other factors, definitely postgresql is better but don’t let this issue be the deciding factor.

Reclaim Deleted Space

Unless you are really really pressed for hard disk space, just let it go. That space will be reused by the database as the table grows again. If you add two million new records you will find that the disc usage hasn’t increased at all.

If you are really pressed for space. OPTIMIZE TABLE. This operation too will take a long time.

👤e4c5

1👍

I would recommend on changing your database management. You can change to PostgreSQL since it is built for larger data storage. Or you can try big data. Just in case your data really gets very very large. Deleting data is not really recommended as you can use it later for analytics.

You can try django and cassandraDB for example. https://github.com/r4fek/django-cassandra-engine

Leave a comment