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 `tbl_category` ADD INDEX `tbl_category_idx_category_id` (`category_id`);
ALTER TABLE `tbl_program` ADD INDEX `tbl_program_idx_progra_name_copyri_active_parent` (`program_id`,`name`,`copyright`,`active_flag`,`parent_program_id`);
ALTER TABLE `xref_category_program` ADD INDEX `xref_program_idx_category_id` (`category_id`);
SELECT
p.parent_program_id,
p.program_id,
p.name,
p.copyright,
p.active_flag,
max(CASE
WHEN c.category_id = 36261 THEN 'X'
ELSE ' ' END) AS CC_Indicator,
max(CASE
WHEN c1.category_id = 36362 THEN 'X'
ELSE ' ' END) AS CC_Badge,
max(CASE
WHEN c2.category_id = 43221 THEN 'X'
ELSE ' ' END) AS CC_Solution
FROM
tbl_program p
JOIN
xref_category_program xcp
ON p.program_id = xcp.program_id
LEFT JOIN
tbl_category c
ON xcp.category_id = c.category_id
AND c.category_id = 36261
LEFT JOIN
tbl_category c1
ON xcp.category_id = c1.category_id
AND c1.category_id = 36362
LEFT JOIN
tbl_category c2
ON xcp.category_id = c2.category_id
AND c2.category_id = 43221
WHERE
xcp.category_id IN (
36261, 36362, 43221
)
GROUP BY
p.program_id,
p.name,
p.copyright,
p.active_flag,
p.parent_program_id
ORDER BY
xcp.program_id