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

Post date: 2022-01-21 17:43:36
Views: 82

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)

Please click Here to read the full story.
 
Other Top and Latest Questions:
Dutch halt state intervention at Chinese-owned chipmaker Nexperia, paving way for exports to resume
Europe has rare earths but, for now, it's at China's mercy like everyone else
Walmart in talks to acquire Israeli-founded startup to combat scams, counterfeits
Jim Cramer's top 10 things to watch in the stock market Wednesday
Trump calls for ABC's license to be revoked after reporter asks about Jeffrey Epstein files
From $1 trillion spending to F-35s, U.S.-Saudi pledges aren't done deals yet
Don't pass up 'free money' during open enrollment, says benefits expert—how to choose FSA and HSA contributions
Mortgage rates hit highest level in a month, pushing loan demand down 5%
The stock market is counting on Nvidia. Here are the 'whisper numbers' the chip giant must deliver
Blue Owl calls off merger of its two private-credit funds after announcement rattles stock