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

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

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:
Sales of new homes tanked in May, pushing supply up to a 3-year high
Movie: Deaf President Now!
Deep inside U.S. economy, more sticker prices start going up due to tariffs, and inventory is headed down
FedEx beats earnings estimates, forecasts $1 billion cost savings in the next fiscal year
Answered: User can create account only with Gmail.
Watch live: Trump speaks after Supreme Court limits judges' power to halt his birthright citizenship order
Dan Niles says investors have to 'forget about' valuations and names his favorite tech stocks
Stocks making the biggest moves midday: Nike, Uber, Newmont, Trade Desk and more
Supreme Court upholds Texas adult website age-verification law
Tesla's European car sales nosedive for fifth month as customers switch to Chinese EVs