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

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

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:
Data centers are concentrated in these states. Here's what's happening to electricity prices
AI to impact 89% of jobs next year, CNBC survey of HR leaders finds
Keep your investments in these 3 accounts, CFP says: 'If you have too much cash, you're actually losing money'
Jana Partners push to break up Cooper Cos. could change the stock's outlook
Trump tariffs are helping drive U.S. beef prices to new highs
MAGA rift grows as Trump feuds with Marjorie Taylor Greene before key 2026 midterm elections
AI anxiety on the rise: Startup founders react to bubble fears
Forget the China gloom — luxury bosses say shoppers are back
Berkshire Hathaway's surprising new tech stake
In defense of junior staff: Why replacing young people with AI could spark a 'talent doom cycle'