Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
331 views
in Q2A Core by
edited by

Does anyone know what this slow sql statement is used for?

SELECT qtoaoi_posts.postid, qtoaoi_posts.categoryid, qtoaoi_posts.type, LEFT(qtoaoi_posts.type, 1) AS `basetype`, INSTR(qtoaoi_posts.type, '_HIDDEN')>0 AS `hidden`, INSTR(qtoaoi_posts.type, '_QUEUED')>0 AS `queued`, qtoaoi_posts.acount, qtoaoi_posts.selchildid, qtoaoi_posts.closedbyid, qtoaoi_posts.upvotes, qtoaoi_posts.downvotes, qtoaoi_posts.netvotes, qtoaoi_posts.views, qtoaoi_posts.hotness, qtoaoi_posts.flagcount, qtoaoi_posts.title, qtoaoi_posts.tags, UNIX_TIMESTAMP(qtoaoi_posts.created) AS `created`, qtoaoi_posts.name, qtoaoi_categories.title AS `categoryname`, qtoaoi_categories.backpath AS `categorybackpath`, CONCAT_WS(',', qtoaoi_posts.catidpath1, qtoaoi_posts.catidpath2, qtoaoi_posts.catidpath3, qtoaoi_posts.categoryid) AS `categoryids`, qtoaoi_posts.userid, qtoaoi_posts.cookieid, qtoaoi_posts.createip AS `createip`, qtoaoi_userpoints.points, qtoaoi_users.flags, qtoaoi_users.level, qtoaoi_users.email AS `email`, qtoaoi_users.handle AS `handle`, BINARY qtoaoi_users.avatarblobid AS `avatarblobid`, qtoaoi_users.avatarwidth, qtoaoi_users.avatarheight, score FROM qtoaoi_posts LEFT JOIN qtoaoi_categories ON qtoaoi_categories.categoryid=qtoaoi_posts.categoryid LEFT JOIN qtoaoi_users ON qtoaoi_posts.userid=qtoaoi_users.userid LEFT JOIN qtoaoi_userpoints ON qtoaoi_posts.userid=qtoaoi_userpoints.userid JOIN (SELECT postid, SUM(score)+LOG(postid)/1000000 AS score FROM ((SELECT qtoaoi_titlewords.postid, LOG(10000/titlecount) AS score FROM qtoaoi_titlewords JOIN qtoaoi_words ON qtoaoi_titlewords.wordid=qtoaoi_words.wordid JOIN qtoaoi_titlewords AS source ON qtoaoi_titlewords.wordid=source.wordid WHERE source.postid=153876 AND titlecount<10000) UNION ALL (SELECT qtoaoi_posttags.postid, 2*LOG(10000/tagcount) AS score FROM qtoaoi_posttags JOIN qtoaoi_words ON qtoaoi_posttags.wordid=qtoaoi_words.wordid JOIN qtoaoi_posttags AS source ON qtoaoi_posttags.wordid=source.wordid WHERE source.postid=153876 AND tagcount<10000) UNION ALL (SELECT qtoaoi_posts.postid, LOG(10000/qtoaoi_categories.qcount) FROM qtoaoi_posts JOIN qtoaoi_categories ON qtoaoi_posts.categoryid=qtoaoi_categories.categoryid AND qtoaoi_posts.type='Q' WHERE qtoaoi_categories.categoryid=(SELECT categoryid FROM qtoaoi_posts WHERE postid=153876) AND qtoaoi_categories.qcount<10000)) x WHERE postid!=153876 GROUP BY postid ORDER BY score DESC LIMIT 10) y ON qtoaoi_posts.postid=y.postid;

Is the following function build this sql? how to close this query or make it faster?

/**

 * Supplement a selectspec returned by qa_db_posts_basic_selectspec() to get information about another post (answer or

 * comment) which is related to the main post (question) retrieved. Pass the name of table which will contain the other

 * post in $poststable. Set $fromupdated to true to get information about when this other post was edited, rather than

 * created. If $full is true, get full information on this other post.

 * @param $selectspec

 * @param $poststable

 * @param bool $fromupdated

 * @param bool $full

 */

function qa_db_add_selectspec_opost(&$selectspec, $poststable, $fromupdated = false, $full = false)

Q2A version: 1.8.5
by
I found if i close the related question widget the cpu run in low rate ,it open the related question widget the cpu run in high rate.

so , is this sql related to this widget?

Please log in or register to answer this question.

...