'Query too long, timeout when using klipfolio
Bästa lösning jag kom på, tackar för du tar dig tid Dom håller på att tjafsa om att jag måste beskriva min kod men har inte så mycket att säga. Antar att problemet är att det för många uträkningar och många tables som joinas. Storleken på queriet är inget märkvärdigt 665 rader, vet inte hur man kollar storleken exakt. Nu tycker den att jag har skrivit tillräckliigt, tack!
VIEW `activity_historic` AS
SELECT
`open_rate_historic`.`month` AS `month`,
`open_rate_historic`.`amb_id` AS `amb_id`,
`open_rate_historic`.`client_Id` AS `client_id`,
`open_rate_historic`.`company` AS `company`,
`open_rate_historic`.`client` AS `client`,
`open_rate_historic`.`retailer` AS `retailer`,
`open_rate_historic`.`country` AS `country`,
COALESCE(`open_rate_historic`.`opens`, 0) AS `opens`,
COALESCE(`open_rate_historic`.`published`, 0) AS `published`,
COALESCE(`challenges_historic`.`accept`, 0) AS `accept`,
COALESCE(`challenges_historic`.`published`, 0) AS `challenge`,
COALESCE(`training_progress_historic`.`completed`,
0) AS `completed`,
COALESCE(`training_progress_historic`.`academies`,
0) AS `academies`,
CONCAT(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1),
'%') AS `activity`,
(CASE
WHEN
(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1) BETWEEN 0 AND 10.99)
THEN
'0-10'
WHEN
(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1) BETWEEN 11 AND 20.99)
THEN
'11-20'
WHEN
(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1) BETWEEN 21 AND 30.99)
THEN
'21-30'
WHEN
(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1) BETWEEN 31 AND 40.99)
THEN
'31-40'
WHEN
(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1) BETWEEN 41 AND 50.99)
THEN
'41-50'
WHEN
(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1) BETWEEN 51 AND 60.99)
THEN
'51-60'
WHEN
(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1) BETWEEN 61 AND 70.99)
THEN
'61-70'
WHEN
(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1) BETWEEN 71 AND 80.99)
THEN
'71-80'
WHEN
(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1) BETWEEN 81 AND 90.99)
THEN
'81-90'
WHEN
(ROUND(((((COALESCE(`open_rate_historic`.`opens`, 0) + COALESCE(`challenges_historic`.`accept`, 0)) + COALESCE(`training_progress_historic`.`completed`,
0)) / ((COALESCE(`open_rate_historic`.`published`, 0) + COALESCE(`challenges_historic`.`published`, 0)) + COALESCE(`training_progress_historic`.`academies`,
0))) * 100),
1) BETWEEN 91 AND 100)
THEN
'91-100'
END) AS `activity_group`
FROM
((`open_rate_historic`
LEFT JOIN `challenges_historic` ON (((`challenges_historic`.`amb_id` = `open_rate_historic`.`amb_id`)
AND (`challenges_historic`.`month` = `open_rate_historic`.`month`)
AND (`challenges_historic`.`year` = `open_rate_historic`.`year`))))
LEFT JOIN `training_progress_historic` ON (((`training_progress_historic`.`amb_id` = `open_rate_historic`.`amb_id`)
AND (`training_progress_historic`.`month` = `open_rate_historic`.`month`)
AND (`training_progress_historic`.`year` = `open_rate_historic`.`year`))))
Skriver lite här nere också och ser om dom blir nöjda. Men det verkar inte så. Va struligt det ska va.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
