In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `scores` ADD INDEX `scores_idx_week_teamid` (`week`,`teamid`);
ALTER TABLE `tickets` ADD INDEX `tickets_idx_week` (`week`);
SELECT
t_id,
t_teamids,
score
FROM
((SELECT
t.id AS t_id,
t.teamids AS t_teamids,
(SELECT
SUM(s1.score)
FROM
scores s1
WHERE
s1.teamid IN (
t.teamids
)
AND s1.week = 11) AS score
FROM
tickets t
WHERE
t.week = 11
AND (
t.teamids LIKE "%,150"
)
)
UNION
DISTINCT (SELECT
t.id AS t_id,
t.teamids AS t_teamids,
(SELECT
SUM(s1.score)
FROM
scores s1
WHERE
s1.teamid IN (t.teamids)
AND s1.week = 11) AS score
FROM
tickets t
WHERE
t.week = 11
AND (t.teamids LIKE "150,%"))
) AS union1