MySQL Forums
Forum List  »  Performance

Re: Query is occasionally sluggish
Posted by: Rick James
Date: July 21, 2013 12:02AM

> occasionally sluggish

As in, sluggish for certain values of userid and/or uid? Could it be that those values have more rows than the others?

> JOIN mentions m ON gq.id = m.questionId
> WHERE
> m.userId = 1

would benefit from
INDEX(userid, questionId)

Should the UNION be UNION ALL or UNION DISTINCT?

Try this: Have the UNION deliver only gq.tid and gq.id (= ga.qid). That is, don't touch group_answer until you get back from the UNION. (This implies no ORDER BY and LIMIT inside the inner SELECTs.)

Part of the sluggishness is hauling around the various fields of ta.

Also, because of these:
`answer` text,
`plaintext` text,
`data` text,
the temp tables cannot be MEMORY, but must be MyISAM.

By dealing with the TEXT fields in the outermost SELECT, you minimize the number of temp tables that need to be MyISAM, and minimize the bulk hauled around.

Options: ReplyQuote


Subject
Views
Written By
Posted
1881
July 18, 2013 01:12PM
Re: Query is occasionally sluggish
923
July 21, 2013 12:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.