我正在使用为 mysql 数据库配置 mod_archive_odbc 的 ejabberd 2.1.12。我在保存单个消息时检查了日志,它们看起来很可怕。Ejabberd 假设是高度可扩展的 xmpp 服务器,但启用此模块后,mysql 数据库可能会成为瓶颈。
日志:
7 Query begin
7 Query select * from archive_global_prefs where us = '6@my.server'
7 Query select * from archive_jid_prefs where us = '6@my.server' and with_user = '4' and with_server = 'my.server' and with_resource = ''
7 Query select * from archive_jid_prefs where us = '6@my.server' and with_user = '4' and with_server = 'my.server' and with_resource = ''
7 Query select * from archive_jid_prefs where us = '6@my.server' and with_user = '' and with_server = 'my.server' and with_resource = ''
7 Query commit
5 Query begin
5 Query update archive_collections set with_resource = '', change_by = '6@my.server/my-resource', change_utc = '2013-05-11 09:47:46', subject = '', thread = '' where id = 9
5 Query insert into archive_messages(coll_id, utc, dir, name, body) values(9, '2013-05-11 09:47:46', 1, '', 'some random message')
5 Query commit
5 Query begin
5 Query select * from archive_global_prefs where us = '4@my.server'
5 Query select * from archive_jid_prefs where us = '4@my.server' and with_user = '6' and with_server = 'my.server' and with_resource = 'my-resource'
5 Query select * from archive_jid_prefs where us = '4@my.server' and with_user = '6' and with_server = 'my.server' and with_resource = ''
5 Query select * from archive_jid_prefs where us = '4@my.server' and with_user = '' and with_server = 'my.server' and with_resource = ''
5 Query commit
3 Query begin
3 Query update archive_collections set with_resource = 'my-resource', change_by = '4@my.server', change_utc = '2013-05-11 09:47:46', subject = '', thread = '' where id = 10
3 Query insert into archive_messages(coll_id, utc, dir, name, body) values(10, '2013-05-11 09:47:46', 0, '', 'some random message')
3 Query commit
这为每条消息提供了 8 次选择、2 次更新和 2 次插入。我查看了插件的代码,发现有多个插入实现,但这仅用于手动存档。
有什么办法可以优化吗?