Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+12 votes
1.0k views
in Q2A Core by
closed by
I have  over 4,000,000 posts ,  and when user post new quesion or when i hide or delete posts it cost much time

is there any way to sovle this problem ,or speed my site?
Q2A version: 1.8.5
by
Please I have the same problem help me solve it

2 Answers

0 votes
by
 
Best answer

This question can be closed, as the below question update the qa  program code

It takes too long to save when user ask questions, why? - Question2Answer Q&A

0 votes
by
edited by

I think i found the reason why delete and hide question cost much time. The reason may be bellow

1. In function "qa_question_delete" of file app/post-update.php,it will recount all the quesions and answers ,not directly increase(decrease)  num  +1/-1,this will cause whole table scan when recount, Do not know why use this way to do this.

2.By the way, I found in function qa_update_counts_for_q ,it will call five child fuction to update same table , is there possible merge these child into one sql opration ?

function qa_question_delete($oldquestion, $userid, $handle, $cookieid, $oldclosepost = null)

{

    require_once QA_INCLUDE_DIR . 'db/votes.php';

    if ($oldquestion['type'] != 'Q_HIDDEN')

        qa_fatal_error('Tried to delete a non-hidden question');

    $params = array(

        'postid' => $oldquestion['postid'],

        'oldquestion' => $oldquestion,

    );

    qa_report_event('q_delete_before', $userid, $handle, $cookieid, $params);

    if (isset($oldclosepost) && ($oldclosepost['parentid'] == $oldquestion['postid'])) {

        qa_db_post_set_closed($oldquestion['postid'], null); // for foreign key constraint

        qa_post_unindex($oldclosepost['postid']);

        qa_db_post_delete($oldclosepost['postid']);

    }

    $useridvotes = qa_db_uservote_post_get($oldquestion['postid']);

    $oldpath = qa_db_post_get_category_path($oldquestion['postid']);

    qa_post_unindex($oldquestion['postid']);

    qa_db_post_delete($oldquestion['postid']); // also deletes any related voteds due to foreign key cascading

    qa_update_counts_for_q(null); 

function "qa_update_counts_for_q" will recount all various count use sql

/**

 * Perform various common cached count updating operations to reflect changes in the question whose id is $postid

 * @param $postid

 */

function qa_update_counts_for_q($postid)

{

    if (isset($postid)) // post might no longer exist

        qa_db_category_path_qcount_update(qa_db_post_get_category_path($postid));

    qa_db_qcount_update();

    qa_db_unaqcount_update();

    qa_db_unselqcount_update();

    qa_db_unupaqcount_update();

    qa_db_tagcount_update();

}

by
Please I have the same problem help me solve it
...