If you have a seperate question, then you should post it as a separate thread and do not hijack old already resolved thread. I have branched out your question.
Openfire stores room messages in memory and then flushes them into database in batches. You can control the interval and the number of messages in a batch in Group Chat > Group Chat Settings > [conference service name] > Other Settings.
You shouldn't be deleting messages from the database directly. I think you need some kind of plugin to do this using Openfire's APIs, but i can't help with that as i'm not a developer.