@peterbo opened this Issue on May 9th 2020 Contributor

Reproducible by creating a dashboard with 10+ widgets and building a segment (e.g. Entry-page == XYZ AND Channel Type == ZXY).

In the database, you can see a lot of queries that are exactly the same and taking up a lot of CPU time while basically querying / sorting the same data:

1b
2b
3b
4b
5b

The given instance is quite small, but real-time segment calculation is very slow. Fixing this could speed up real-time segment archiving a lot.

An example for one of those queries running simultaneously:
`INSERT INTO logtmpsegmentb4ca4bef0234682057a466a33290929d (idvisit) / idSegments = [83] /

        SELECT
            distinct log_visit.idvisit as idvisit
        FROM
            log_visit AS log_visit
        WHERE
            ( log_visit.visit_last_action_time >= '2020-03-31 22:00:00'
            AND log_visit.visit_last_action_time <= '2020-04-30 21:59:59'
            AND log_visit.idsite IN ('195') )
            AND
            ( log_visit.referer_type = '6' AND log_visit.visit_entry_idaction_url = '209938' )
        ORDER BY
            log_visit.idvisit ASC

INSERT INTO logtmpsegmentb4ca4bef0234682057a466a33290929d (idvisit) / idSegments = [83] /

        SELECT
            distinct log_visit.idvisit as idvisit
        FROM
            log_visit AS log_visit
        WHERE
            ( log_visit.visit_last_action_time >= '2020-03-31 22:00:00'
            AND log_visit.visit_last_action_time <= '2020-04-30 21:59:59'
            AND log_visit.idsite IN ('195') )
            AND
            ( log_visit.referer_type = '6' AND log_visit.visit_entry_idaction_url = '209938' )
        ORDER BY
            log_visit.idvisit ASC`
@tsteur commented on May 9th 2020 Member
@peterbo commented on May 9th 2020 Contributor

Hey @tsteur! Some of the commenters are talking about different things, but Matt's comment is exactly it:

if one loads dashboard, and 10 widgets call the API at the same time (same second), we expect that Piwik will trigger archiving only once (in one thread) and other threads will wait for this process, then when archiving is finished all widgets loading will be unblocked and will read this same archive

@tsteur commented on May 9th 2020 Member

Cheers, will mark it as a duplicate for now.

This Issue was closed on May 9th 2020
Powered by GitHub Issue Mirror