Duplicate entry + Slow Query + Php error

#1
Hi i am having duplicate entry/slow query in my dropshipping woocommerce website. also checked my php errorlog and i see over 4482 error that states below:


[12-Oct-2019 20:29:26 UTC] WordPress database error Duplicate entry '65444-9' for key 'PRIMARY' for query INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`) VALUES (65444, 9) made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, rest_api_loaded, WP_REST_Server->serve_request, WP_REST_Server->dispatch, adsw\Api\v1\Update->action, adsw\Api\v1\Actions\Actions->get_params, adsw\Api\v1\Actions\Update->action_update, adsw\Api\v1\Actions\Update->action_update_product, Ali\AliImport->update, Ali\AliImport->doUpdate, Ali\AliImport->updateVariations, wc_update_product_stock, WC_Product->save, WC_Data_Store->update, WC_Product_Variation_Data_Store_CPT->update, WC_Product_Variation_Data_Store_CPT->update_visibility, wp_set_post_terms, wp_set_object_terms
[13-Oct-2019 00:00:11 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8388616 bytes) in /home/customer/
[12-Oct-2019 20:29:26 UTC] WordPress database error Duplicate entry '65444-9' for key 'PRIMARY' for query INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`) VALUES (65444, 9) made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, rest_api_loaded, WP_REST_Server->serve_request, WP_REST_Server->dispatch, adsw\Api\v1\Update->action, adsw\Api\v1\Actions\Actions->get_params, adsw\Api\v1\Actions\Update->action_update, adsw\Api\v1\Actions\Update->action_update_product, Ali\AliImport->update, Ali\AliImport->doUpdate, Ali\AliImport->updateVariations, wc_update_product_stock, WC_Product->save, WC_Data_Store->update, WC_Product_Variation_Data_Store_CPT->update, WC_Product_Variation_Data_Store_CPT->update_visibility, wp_set_post_terms, wp_set_object_terms
[13-Oct-2019 00:00:11 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8388616 bytes) in /home/customer/
[12-Oct-2019 20:29:26 UTC] WordPress database error Duplicate entry '65444-9' for key 'PRIMARY' for query INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`) VALUES (65444, 9) made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, rest_api_loaded, WP_REST_Server->serve_request, WP_REST_Server->dispatch, adsw\Api\v1\Update->action, adsw\Api\v1\Actions\Actions->get_params, adsw\Api\v1\Actions\Update->action_update, adsw\Api\v1\Actions\Update->action_update_product, Ali\AliImport->update, Ali\AliImport->doUpdate, Ali\AliImport->updateVariations, wc_update_product_stock, WC_Product->save, WC_Data_Store->update, WC_Product_Variation_Data_Store_CPT->update, WC_Product_Variation_Data_Store_CPT->update_visibility, wp_set_post_terms, wp_set_object_terms


[13-Oct-2019 21:37:02 UTC] WordPress database error Duplicate entry '60033-9' for key 'PRIMARY' for query INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`) VALUES (60033, 9) made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, rest_api_loaded, WP_REST_Server->serve_request, WP_REST_Server->dispatch, adsw\Api\v1\Update->action, adsw\Api\v1\Actions\Actions->get_params, adsw\Api\v1\Actions\Update->action_update, adsw\Api\v1\Actions\Update->action_update_product, Ali\AliImport->update, Ali\AliImport->doUpdate, Ali\AliImport->updateVariations, wc_update_product_stock, WC_Product->save, WC_Data_Store->update, WC_Product_Variation_Data_Store_CPT->update, WC_Product_Variation_Data_Store_CPT->update_visibility, wp_set_post_terms, wp_set_object_terms, QM_DB->query
 
#2
From what i know of MySQL i would probbaly do this as the first attempt to fix it :

Code:
mysqldump -uUSER -pPASSWORD DBNAME > /tmp/my_backup.sql
to create backup of the database, then i would :

Code:
drop database DBNAME;
to delete the DB, then :

Code:
create database DBNAME;
to recreate DB, then :

Code:
mysql -uUSER -pPASSWORD DBNAME < /tmp/my_backup.sql
This should achieve re-indexing of the DB and hopefully removing the duplicate PRIMARY KEY
 
#3
Hi i don't know how to run this query
mysqldump -uUSER -pPASSWORD DBNAME > /tmp/my_backup.sql

what if i download my database via the normal setting?

I just migrated my site to another live server and my old database was uploaded and i am still getting duplicate and slow queries but not as much as before.
 
#5
what if i recreate new DB manually via cPanel and i import the former DB sql file into the newly created DB? will it work that way?
Sorry i was traveling .... the best option is the db reload .... but i can check other options ... what version of mysql are you using ?
 
Top