PennyDreadfulMTG / perf-reports

2 stars 2 forks source link

Exceeded slow_query limit (47.6 > 30.0) in mysql: ``` #53778

Open vorpal-buildbot opened 4 years ago

vorpal-buildbot commented 4 years ago
    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 47.6, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (55.1 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 55.1, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (49.0 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 49.0, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (48.3 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 48.3, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (52.7 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 52.7, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (55.1 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 55.1, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (52.5 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 52.5, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (52.2 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 52.2, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (51.8 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 51.8, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (52.3 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 52.3, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (51.0 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 51.0, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (52.8 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 52.8, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (52.2 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 52.2, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (53.5 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 53.5, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (50.3 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 50.3, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (51.1 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 51.1, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (51.0 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 51.0, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (53.2 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 53.2, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (50.6 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 50.6, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (55.1 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 55.1, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (50.0 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 50.0, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (54.6 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 54.6, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (54.4 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 54.4, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (51.1 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 51.1, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (46.1 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 46.1, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (50.0 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 50.0, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (49.2 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 49.2, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (50.0 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 50.0, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (52.3 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 52.3, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (50.4 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 50.4, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (49.9 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 49.9, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (54.0 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 54.0, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (52.1 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 52.1, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (51.9 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 51.9, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (53.5 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 53.5, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (52.3 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 52.3, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (52.9 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 52.9, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (54.5 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 54.5, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite

vorpal-buildbot commented 4 years ago

Exceeded slow_query limit (53.0 > 30.0) in mysql: ```

    CREATE TABLE IF NOT EXISTS _new_card_stats (
        name VARCHAR(190) NOT NULL,
        season_id INT NOT NULL,
        num_decks INT NOT NULL,
        wins INT NOT NULL,
        losses INT NOT NULL,
        draws INT NOT NULL,
        perfect_runs INT NOT NULL,
        tournament_wins INT NOT NULL,
        tournament_top8s INT NOT NULL,
        deck_type ENUM('league', 'tournament', 'other') NOT NULL,
        PRIMARY KEY (season_id, name, deck_type),
        FOREIGN KEY (season_id) REFERENCES season (id) ON UPDATE CASCADE ON DELETE CASCADE
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci AS
    SELECT
        card AS name,
        season.id AS season_id,
        SUM(CASE WHEN d.id IS NOT NULL THEN 1 ELSE 0 END) AS num_decks,
        IFNULL(SUM(wins), 0) AS wins,
        IFNULL(SUM(losses), 0) AS losses,
        IFNULL(SUM(draws), 0) AS draws,
        SUM(CASE WHEN wins >= 5 AND losses = 0 AND d.source_id IN (SELECT id FROM source WHERE name = 'League') THEN 1 ELSE 0 END) AS perfect_runs,
        SUM(CASE WHEN dsum.finish = 1 THEN 1 ELSE 0 END) AS tournament_wins,
        SUM(CASE WHEN dsum.finish <= 8 THEN 1 ELSE 0 END) AS tournament_top8s,
        (CASE WHEN ct.name = 'League' THEN 'league' WHEN ct.name = 'Gatherling' THEN 'tournament' ELSE 'other' END) AS deck_type
    FROM
        deck AS d
    INNER JOIN
        -- Eiliminate maindeck/sideboard double-counting with DISTINCT. See #5493.
        (SELECT DISTINCT card, deck_id FROM deck_card) AS dc ON d.id = dc.deck_id

    LEFT JOIN
        competition AS c ON d.competition_id = c.id
    LEFT JOIN
        competition_series AS cs ON cs.id = c.competition_series_id
    LEFT JOIN
        competition_type AS ct ON ct.id = cs.competition_type_id

    LEFT JOIN
        (
            SELECT
                `start`.id,
                `start`.code,
                `start`.start_date AS start_date,
                `end`.start_date AS end_date
            FROM
                season AS `start`
            LEFT JOIN
                season AS `end` ON `end`.id = `start`.id + 1
        ) AS season ON season.start_date <= d.created_date AND (season.end_date IS NULL OR season.end_date > d.created_date)

    LEFT JOIN
        (
            SELECT
                d.id,
                d.created_date,
                d.finish,
                SUM(CASE WHEN dm.games > IFNULL(odm.games, 0) THEN 1 ELSE 0 END) AS wins, -- IFNULL so we still count byes as wins.
                SUM(CASE WHEN dm.games < odm.games THEN 1 ELSE 0 END) AS losses,
                SUM(CASE WHEN dm.games = odm.games THEN 1 ELSE 0 END) AS draws
            FROM
                deck_match AS dm
            INNER JOIN
                deck_match AS odm ON dm.match_id = odm.match_id AND dm.deck_id <> odm.deck_id
            INNER JOIN
                deck AS d ON d.id = dm.deck_id
            GROUP BY
                d.id
        ) AS dsum ON d.id = dsum.id

    GROUP BY
        card,
        season.id,
        ct.name
```

[] (slow_query, 53.0, mysql)

Reported on decksite by mysql-perf

Location Hash: 1e520342053e1bad7d833af0caa0b7024f18948f

Labels: decksite