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

First I did direct import of posts to DB in phpmyadmin. So now I need recount, reindex etc.

Reindex content done, recalculate categories done, recalculate user points done. But when I start Recount posts its work ~300-350 k post (from 650 k ) and I take "A database error occurred." 

I try start it in browser without JavaSript, but of course script can't work such long time. 

How can I solve it?

And maybe somebody know good varints how do import of Q and A from CSV correctly, with all indexes? Read this https://www.question2answer.org/qa/1222/what-is-the-best-way-for-me-to-upload-lot-of-questions-to-the-db,  but as I undestand its for old version and honestly hard for my understend.

TNX

UPD: starting process early morning, when server with minimal load - first part with recalculate votes and flags done, but second with answers and hotness broken again at ~50 000. Is it psible to turn off first part with votes and flags? Wich file have this function?

Q2A version: 1.8.3
by
It will be important to report the details of error messages in the DB(MySQL) on your question. For example, timeout, lack of resources, daemon down etc ...

2 Answers

0 votes
by

Can answer for second part of my question: file qa-include/db/recalc.php.

Need change:

function qa_db_posts_votes_recount($firstpostid, $lastpostid)

{

qa_db_query_sub(

'UPDATE ^posts AS x, (SELECT ^posts.postid, COALESCE(SUM(GREATEST(0,^uservotes.vote)),0) AS upvotes, -COALESCE(SUM(LEAST(0,^uservotes.vote)),0) AS downvotes, COALESCE(SUM(IF(^uservotes.flag, 1, 0)),0) AS flagcount FROM ^posts LEFT JOIN ^uservotes ON ^uservotes.postid=^posts.postid WHERE ^posts.postid>=# AND ^posts.postid<=# GROUP BY postid) AS a SET x.upvotes=a.upvotes, x.downvotes=a.downvotes, x.netvotes=a.upvotes-a.downvotes, x.flagcount=a.flagcount WHERE x.postid=a.postid',

$firstpostid, $lastpostid

);

qa_db_hotness_update($firstpostid, $lastpostid);

}

to 

function qa_db_posts_votes_recount($firstpostid, $lastpostid)

{/*

qa_db_query_sub(

'UPDATE ^posts AS x, (SELECT ^posts.postid, COALESCE(SUM(GREATEST(0,^uservotes.vote)),0) AS upvotes, -COALESCE(SUM(LEAST(0,^uservotes.vote)),0) AS downvotes, COALESCE(SUM(IF(^uservotes.flag, 1, 0)),0) AS flagcount FROM ^posts LEFT JOIN ^uservotes ON ^uservotes.postid=^posts.postid WHERE ^posts.postid>=# AND ^posts.postid<=# GROUP BY postid) AS a SET x.upvotes=a.upvotes, x.downvotes=a.downvotes, x.netvotes=a.upvotes-a.downvotes, x.flagcount=a.flagcount WHERE x.postid=a.postid',

$firstpostid, $lastpostid

);

qa_db_hotness_update($firstpostid, $lastpostid);

*/} 

0 votes
by

I don't know what happens, but today "Recount post" work very fast, ~30000 per second. Before it was just 1000 per 3-4 second.

So it was recalculate without problem.

Last who recalculate very slow - its "Refill event streams - for each user's list of updates". Speed ~ 100 points per sec.

Maybe somebody know why it's so and what to do?

Recount posts"

Recount posts"

...