I recently upgraded my Mattermost server from version 5.31.0 to 7.9.1, and I noticed that the API endpoint “Get channel statistics” has become significantly slower, taking 20 times longer than before:
In v5.31.0: 77 ms with 565 B of response size
In v7.9.1: 1525 ms with 525 B of response size
I’m wondering if there are any possible solutions to fix this performance issue?
can you look at the query that is being executed in the database while you access this API endpoint? What database are you using? MySQL or PostgreSQL?
I’m using PostgreSQL postgres:12-alpine
Where can I find this log?
That’s not a log, but you would need to be connected to your PostgreSQL instance and run the following query after you’ve started the API call:
select pid,backend_start,query_start,state_change,waiting,state,query from pg_stat_activity;
this will show you a list of currently running queries, maybe one of them is slow - you can run the queries on the command line then to see which one of them is the slow one.
Sorry I cannot find out which query is related to the API.
I found that the v5.31.0 response is like this:
v7.9.1 is like this:
Does the presence or absence of the “files_count” field cause the problem?
I think it’s the problem, after setting exclude_files_count=true, the performance became better. (47 ms 526 B)
Alright, nice finding - the file count is obviously new here and requires querying additional tables which results in longer execution times. Good to hear that by restoring the previous behaviour you’re able to achieve the same speeds again.