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

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

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:
Nasdaq falls more than 2% to post sixth straight losing day as Nvidia craters 10%: Live updates
Here's what 12 European Central Bank members said about interest rates this week
Men's "Evening dress" for museum show opening - what's that look like?
strap
Sewing More than Fabric
Movie: Dead End Drive-In
How a Jack Dorsey-backed bitcoin miner uses a volcano in Kenya to turn on the lights in rural homes
Buy these five stocks ahead of earnings before it's too late, Bank of America says
This Ohio cabin was just named one of the top 10 vacation rentals in the world—check it out
Tesla recalls Cybertruck over 'trapped pedal' issue seen in owner's viral TikTok video