jeudi 3 mars 2016

Clean database table after huge delete

I have a mileage logbook app that’s allows the user to track his way and various OBDII parameters.

As you can imagine the tables for OBDII-data and GPS-Coordinates can become quite big and slows ma app down.

Therefore, I created a cleanup-utility that allows my users to delete data older than a selected date. Unfortunately, this does not speed up my app again even if the database file is smaller. I already read that this is caused by fragmentation of the database table and the quite high prime keys. I already tried VACUUM but this is not working. I tried to find out what is going wrong but no exception occurs. The activity is just closing unexpectedly.

I’m also not sure if VACUUM is the right command for me since I just need to optimize two tables. It is also not important that the prime keys keep the same for me.

Maybe I should just create a temporary table -> copy the data from the original table to this new one -> drop the original table -> and rename the temporary table to the original one? Does anyone have a better idea?

Cheers, Stefan

Aucun commentaire:

Enregistrer un commentaire