0
私のクエリを実行するために数分を要し、クエリ、それはMySQLのクエリの最適化や短縮私はこのクエリを短くして作ることができる方法
SELECT *
FROM
(
SELECT distinct(ja.applied_recruiter_id) as r_ids
FROM (`game_applied` AS ja)
JOIN `games_post` AS jp ON `jp`.`id` = `ja`.`game_post_id`
JOIN `user_user` AS uu ON `uu`.`id` = `ja`.`applied_recruiter_id`
WHERE `ja`.`game_post_id` = j_id
AND `uu`.`user_member_type_id` = 2
AND `jp`.`status` NOT IN ('3', '6', '7')
UNION
SELECT distinct(jr.referby_user_id) as r_ids
FROM (`game_refer` AS jr)
JOIN `games_post` AS jp ON `jp`.`id` = `jr`.`game_id`
JOIN `user_user` AS uu ON `uu`.`id` = `jr`.`referby_user_id`
WHERE `jr`.`game_id` = j_id
AND `uu`.`user_member_type_id` = 2
AND `jp`.`status` NOT IN ('3', '6', '7')
UNION
SELECT distinct(js.referrer_id) as r_ids
FROM (`game_share_log` AS js)
JOIN `games_post` AS jp ON `jp`.`id` = `js`.`game_id`
JOIN `user_user` AS uu ON `uu`.`id` = `js`.`referrer_id`
WHERE `js`.`game_id` = j_id
AND `uu`.`user_member_type_id` = 2
AND `jp`.`status` NOT IN ('3', '6', '7')
UNION
SELECT distinct(uf.user_user_id) as r_ids
FROM (`user_follow_company` AS uf)
JOIN `user_user` AS uu ON `uu`.`id` = `uf`.`user_user_id`
WHERE `uf`.`gamer_company_id` = c_id
AND `uu`.`user_member_type_id` = 2
UNION
SELECT distinct(rj.user_id) as r_ids
FROM (`recruiter_game_views` AS rj)
JOIN `games_post` AS jp ON `jp`.`id` = `rj`.`game_id`
JOIN `user_user` AS uu ON `uu`.`id` = `rj`.`user_id`
WHERE `rj`.`game_id` = j_id
AND `uu`.`user_member_type_id` = 2
AND `jp`.`status` NOT IN ('3', '6', '7')
UNION
SELECT distinct(`jf`.`user_id`) as r_ids
FROM (`games_favourite` AS `jf`)
JOIN `games_post` AS `jp` ON `jp`.`id` = `jf`.`game_post_id`
JOIN `user_user` AS `uu` ON `uu`.`id` = `jf`.`user_id`
WHERE `jf`.`game_post_id` = j_id
AND `uu`.`user_member_type_id` = 2 AND `jf`.`game_favourite_status` = '1'
AND `jp`.`status` NOT IN ('3', '6', '7')
UNION
SELECT distinct (`jiu`.`user_id`) as r_ids
FROM (`game_insight_user` AS `jiu`)
JOIN `game_insight` AS `ji` ON `ji`.`id` = `jiu`.`insight_id`
WHERE `ji`.`game_post_id` = j_id
) AS r_ids
WHERE r_ids not in (SELECT referby_user_id FROM game_refer_to_member jrm1 JOIN game_refer jr ON jrm1.rid = jr.id JOIN user_socialconnections AS ruef ON (jrm1.referto_addressbookid = ruef.id) JOIN user_user AS eu1 ON jr.referby_user_id = eu1.id WHERE 1=1 AND jrm1.id in (select DISTINCT(referred_by) as referred_by from game_applied where game_post_id = j_id))
テーブル構造を提供し、達成しようとしていることを説明してください。 – Bentaye
確かに..テーブル構造を提供します..データを取得するのに10分以上かかる場合 – dude
Grrrrrr ...クエリでは 'j_id'がどのテーブルに入っているのかわからないので、 'SHOW CREATE TABLE'。 –