Innefficient database fetch in check results

Home Forums Legacy Support Support queries Setup issues Innefficient database fetch in check results

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #352725
    SuperDave
    Spectator
    Hello, in theme file wplms/members/single/course/results.php on line 92 you make use of the WordPress function as follows: $comments = $comments_query->query( array('post_id'=> $question,'user_id'=>$user_id,'number'=>1,'status'=>'approve') ); This function has vast inefficiencies and shouldn't be used the way it's being used. The database query this function generates is much too generalised and slow. When there are thousands of users on the site the execution of this script can take up to 76 seconds ( I tested using xdebug profiler) on a powerful dedicated server. In order to resolve the issue for our users I replaced line 92 with this query: $comments = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}comments WHERE comment_post_id = {$question} and comment_approved = 1 and user_id = {$user_id}", OBJECT ); Which is much faster, making a 76 second query go down to a 4.6 second query. Thank you.
    #352921
    Anshuman Sahu
    Keymaster
    Yes this is why we are not using it anymore in our new react quizzes ,If you are using wplms ad vibebp plugins then dont worry this wont execute . Also if you are on 3.9.x version then please enable react quizzes . https://wplms.io/support/knowledge-base/quizzes-on-react/
    #353298
    SuperDave
    Spectator
    Big thanks !!
    #353334
    Veronica
    Moderator
    good to know this information helps you closing this one
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Innefficient database fetch in check results’ is closed to new replies.