-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance Problem with matomo_session Table #22767
Comments
Another point I have just realised (but not verified yet), is that this could perhaps explain why sometimes the Redis queue grows very quickly and adding workers seems to have little effect (at least until the tracking events spike calms down):
So perhaps another reason why the platform will likely benefit from seeing that query optimised. |
Adding an index could possibly speed up queries on that table. But to be honest, I'm wondering what is happening on your installation, that there are so many records in that table 🤔 |
Do you mean the session table is only used when a user accesses the matomo web-ui? I am asking because the majority of our users are authenticated and we do provide it to the analytics via "setUserId". So I wonder if that could cause the creation of the sessions 🤔
Do you mean "is there anonymous access to the Matomo web-ui"? |
Yes, exactly. Tracking should not cause any records in the session table.
No.
I meant the feature to enable anonymous access to a Matomo site. That allows anyone to view statistics without being logged in. It's disabled by default. How many concurrent users does your Matomo instance have? And how many records are stored in the session table? |
The matomo_session table currently contains 713,192 records. From the looks of it, I would say they mostly get deleted after 14 days by the delete query (lifetime 1209600). This is on a test system (staging), on which 22 Matomo users are currently defined. Now some of the tests on that system are driven by EndTest, so I am starting to wonder if one of the tests is currently just loading the login page to test that the system is up and that could perhaps trigger the creation of the session. Still, this is a bit concerning for us as the plan is to have many virtual websites (tracked by the Matomo instance) and allow many (authenticated) users (per virtual website) to check their virtual website stats. It is good to know that this should not affect the tracking or queuedtracking at all, but the potential of the matomo-session table causing DB overload is still a concern (could easily be turned in to a DoS amplifier I would suspect). |
A user reported that they are using Matomo with the Premium plugins and looking at their DB performance stats. They have noticed one issue that seems to be caused by the matomo_session table.
It seem to be deleting the ongoing session with the query:
DELETE FROM
matomo_session
WHEREmodified
+lifetime
< ?The problem is that these fields are not indexed and the use of a calculated query (the use of sum) means they would not be used anyway. And this causes a full table scan relatively regularly and that makes it appear in the list of most expensive queries:
They also mentioned that it causes the insert cost to be non-negligible (lock contention with the ongoing delete?).
Additional feedback:
_It possibly would be an idea to change the "modified" to an "expired" one. That way you could still have a changeable "lifetime", have the "expiry" pre-calculated and updating it would just be a story of setting it to "now+lifetime"...
Then you would just have to add an index for the "expiry" field. In that scenario the delete cost would come to almost nothing. And the insert cost would not change that much either (there would be the index cost but on the other hand there would be less waiting for lock)._
They are using the Queued Plugin, meaning these effects are not visible from the clients but the DB strain is still there.
The text was updated successfully, but these errors were encountered: