Skip to content
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 issue with retrieving segmented visitor log by Event Category/Action/Name #14784

Closed
siva538 opened this issue Aug 18, 2019 · 1 comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Milestone

Comments

@siva538
Copy link
Contributor

siva538 commented Aug 18, 2019

Hello All -

Wanted to bring to your notice an issue with the viewing of Segmented Visitor Log, of Event Categories/Actions/Names.

The query trying to retrieve Segmented visitor log (top 50 records), for a given Event Action is taking close to 4 minutes.

Here is the query for reference:

`SELECT sub.* FROM (

		SELECT
			log_inner.*
		FROM
			
    (
        
		SELECT
			log_visit.*
		FROM
			matomo_log_visit AS log_visit 
			LEFT JOIN matomo_log_link_visit_action AS log_link_visit_action ON 
			log_link_visit_action.idvisit = log_visit.idvisit
		WHERE
			( log_visit.idsite IN ('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33') /* other sizes are not mentioned considering the length */
			AND log_visit.visit_last_action_time >= '2019-07-01 04:00:00'
			AND  log_visit.visit_last_action_time <= '2019-08-01 04:00:00' )
            AND
            ( log_link_visit_action.idaction_event_action = '489906' )
		ORDER BY
			visit_last_action_time DESC LIMIT 0, 510
    ) AS log_inner
		ORDER BY
			visit_last_action_time DESC
		) AS sub
		GROUP BY sub.idvisit
		ORDER BY sub.visit_last_action_time DESC
	LIMIT 51;`

After due investigation, it was identified that there a missing on log_link_visit_action table, that is causing the entire MYSQL box crazy.

Here is the index for reference:

CREATE INDEX index_idaction_event_action ON matomoprod.matomo_log_link_visit_action (idaction_event_action ASC) ;

This actually did the trick. Though we are trying to retrieve the data for a month range, the query started taking < 1-2 sec, compared to 4 mins earlier.

Also as a general thumb rule we add foreign key indexes on the transaction tables, for faster retrieving of the data.

Till we have a broader solution to address this as mentioned in the below issue (i.e. splitting log_link_visit_action table), indexes should help address the problem
https://github.com/matomo-org/matomo/issues/14119

Thanks in advance.

Regds,
Sivakumar

@tsteur
Copy link
Member

tsteur commented Aug 18, 2019

Thanks @siva538

We've actually made some more performance improvements to visitor log as part of 3.12 (maybe even 3.11 not sure).

Adding an index can always help with specific queries but we won't be adding any new indexes as everyone has different segments and we can't add heaps of indexes.

Be good to check out 3.12 once it's out. It might improve the performance there as well.

@tsteur tsteur closed this as completed Aug 18, 2019
@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label Aug 18, 2019
@mattab mattab added this to the 3.12.0 milestone Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

3 participants