removing members in existing databases

#1

Hi team


i might ask for the best practice to remove some members (i.e. collections) in existing databases. There are several aproaches and I'm not shure wich on is best.

1. Just make the list empty and let it remain in database
2. Remove the list and
  2.a update every object that contains this (now removed) list
  2.b compute a database defragmentation with

       String[] args = {old_db_file, new_db_file};
       com.objectdb.Doctor.main(args);

2.a is very expensive which means it takes a lot of time if you have a lot of objects in your db
2.b when testing it works fine for me in a very suitable amount of time. I checked in explorer and the unused members are gone and it seems that the database worked fine as before

but I was not shure wether 2.b is really safe. If 2.b is an acceptable aproach i have a next question:
Is reendexing done automaticly, especially if you have new indexes or do I have to rely on

      <index-update enabled="true" priority="30" />

best regards
Arne

#2

Hi,

Option 1, clearing list fields and keeping orphan objects is the database (if understood correctly) is possible but it will waste database space, so the benefit is unclear. Alternatively you can move the references to objects for deletion to a special "queue" list and delete objects in the background in a low priority thread. It also seems that it will be slow as option 2a, as emptying list fields updates the objects that contain them.

Note that you also have the option of defining list fields as mapped by / inverse and in that case in practice you can only delete objects and the lists will be updated automatically. Mapped by fields, however, are much slower, as they are computed when needed using queries (defining indexes on the owner fields can help).

Regarding the Doctor, although it is not intended for this use, if it works for you then you can choose this option. As a bonus, all indexes are expected to be rebuilt. Not sure about inactive indexes, but there is no practical reason not to rebuild them as well, so if you find that they are not built we can fix that. Note that this option will require your database to be offline.

The last build, 2.8.9_06 adds a better way to run the Doctor from your program:

String output = Doctor.run(srcPath, dstPath);

It is not only cleaner and shorter but also returns the output (instead of writing to the standard output).

Regards,

ObjectDB Support
#3

thanks for your quick reply. The objects itself should remain in database and will be available by query, so it's only about removing the lists and leave the objects in the database.
As a result rebuild the database is an good option. I'm not really sure about this answer:
    As a bonus, all indexes are expected to be rebuilt.
does this mean they will rebuild (in background) next time I open the database or during rebuild the database?

best regards and thank you for the excellent support
Arne

#4

When the Doctor finishes, the new generated database file will have the rebuilt indexes ready to use. Again, it means some downtime when the Doctor is working but then you can switch to the new database that will be ready with the indexes.

ObjectDB Support
#5

thanks again

Reply