Check performance of Tig_MA_RemoveMessages store procedure (#83)
Andrzej Wójcik (Tigase) opened 1 month ago

Check performance of Tig_MA_RemoveMessages store procedure as following part of it causes rather large impact on database:

delete from tig_ma_jids
            where
                not exists (
                    select 1 from tig_ma_msgs m where m.owner_id = jid_id
                )
                and not exists (
                    select 1 from tig_ma_msgs m where m.buddy_id = jid_id
                );
Andrzej Wójcik (Tigase) added "Related" tigase-private/systems-maintenance/servers#384 1 month ago
Andrzej Wójcik (Tigase) changed state to 'In QA' 1 month ago
Previous Value Current Value
Open
In QA
Andrzej Wójcik (Tigase) commented 1 month ago

After analysis of this query performance it looks like it works fast if I/O is not restricted (ie. due to limits on a hardware side). All queries are done using indexes so there is nothing to optimize.

We could record jids that were used in messages that were removed and check just them, but I do not think this will have a major impact on the installation.

Wojciech Kapcia commented 1 month ago

Is there any hint about performance in explain delete?

Andrzej Wójcik (Tigase) commented 1 month ago

I've checked those deletes and it iterates over all jids as it has to, but it does a very fast check against tig_ma_msgs as it uses indexes to verify if particular row from tig_ma_jids is used.

Wojciech Kapcia commented 2 weeks ago

So basically again a case to de-normalize the schema?

Andrzej Wójcik (Tigase) commented 2 weeks ago

Yes, we could denormalize schema and make one big table and that should work well, however that would created JID duplication, but I'm not sure we need to worry about that.

Wojciech Kapcia commented 2 weeks ago

I'd say duplication would be less of a tradeoff in this case than dealing with full-row scans. AFAIR normalization is not always the best solution.

Wojciech Kapcia commented 1 day ago

I was restarting our test server instance and I noticed that there seems to be an error in the schema:

xmpp-1  |   		         Loading schema from file(s): postgresql-message-archiving-3.3.0.sql, URI: jdbc:postgresql://db/tigasedb?user=tigase_user&password=***********
xmpp-1  |   		         Failed to execute query: do $$ begin if exists (select 1 where (select to_regclass('public.tig_ma_msgs_ts_index')) is not null) then drop index tig_ma_msgs_ts_index on tig_ma_msgs; end if; end$$
xmpp-1  |
xmpp-1  |
xmpp-1  |
xmpp-1  |   		         =====
xmpp-1  |   		         Failure: ERROR: syntax error at or near "on"
xmpp-1  |   		           Position: 141
xmpp-1  |   		         =====
xmpp-1  |
xmpp-1  |
xmpp-1  |   		         Failure: ERROR: syntax error at or near "on"
xmpp-1  |   		           Position: 141
Referenced from commit 17 hours ago
issue 1 of 1
Type
Task
Priority
Normal
Assignee
Version
none
Sprints
n/a
Customer
n/a
Iterations
Issue Votes (0)
Watchers (3)
Reference
tigase/_server/tigase-message-archiving#83
Please wait...
Page is in error, reload to recover