I am having trouble using a derived table in MySQL. Does using a derived table inherently slow down the processing of a query?
Here is the query I am trying to run. It won't execute and just times out.
It does succeed. Really, I have isolated the problem to the last join. When I take out the last join it works fine. But when I add the last join back in it refuses to execute.
SELECT cr.COMMUNICATIONS_ID AS ANSWER_ID,
cr.CONSUMER_ID as VIEWER_ID,
cr.ACTION_LOG_ID,
nc.PARENT_COMMUNICATIONS_ID AS QUESTION_ID,
nc.SENDER_CONSUMER_ID AS REPLIER_ID,
ces.EXPERT_SCORE AS REPLIER_EXPERTISE,
cim.CONSUMER_INTEREST_EXPERT_ID AS DOMAIN
FROM (SELECT 234 AS CONSUMER_ID,
ACTION_LOG_ID,
COMMUNICATIONS_ID
FROM consumer_action_log
WHERE COMM_TYPE_ID=4) AS cr
JOIN network_communications AS nc ON
cr.COMMUNICATIONS_ID=nc.COMMUNICATIONS_ID
JOIN communication_interest_mapping AS cim ON
nc.PARENT_COMMUNICATIONS_ID=cim.COMMUNICATION_ID
JOIN consumer_expert_score AS ces ON
nc.SENDER_CONSUMER_ID=ces.CONSUMER_ID
AND cim.CONSUMER_INTEREST_EXPERT_ID=ces.CONSUMER_EXPERT_ID;