Title: Query wc_admin_notes table everywhere
Last modified: June 3, 2023

---

# Query wc_admin_notes table everywhere

 *  Resolved [diegpl](https://wordpress.org/support/users/diegpl/)
 * (@diegpl)
 * [3 years ago](https://wordpress.org/support/topic/query-wc_admin_notes-table-everywhere/)
 * I have a wpms installation with many sites and I see this table is being queried
   in every single page of backend, even in posts lists, with no reason, which is
   preventing me to achieve a better performance. How can I stop that query through
   coding? Tks! 😉

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [diegpl](https://wordpress.org/support/users/diegpl/)
 * (@diegpl)
 * [3 years ago](https://wordpress.org/support/topic/query-wc_admin_notes-table-everywhere/#post-16792490)
 * The function is in woocommerce/src/Admin/Notes/Notes.php
 *     ```wp-block-code
       /**
       	 * Delete actioned survey notes.
       	 */
       	public static function possibly_delete_survey_notes() {
       		$data_store = self::load_data_store();
       		$note_ids   = $data_store->get_note_ids_by_type( Note::E_WC_ADMIN_NOTE_SURVEY );
   
       		foreach ( $note_ids as $note_id ) {
       			$note = self::get_note( $note_id );
       			if ( $note && ( $note->get_status() === Note::E_WC_ADMIN_NOTE_ACTIONED ) ) {
       				$note->set_is_deleted( 1 );
       				$note->save();
       			}
       		}
       	}
       ```
   
 * I tried this code to prevent that with no success:
 *     ```wp-block-code
       function prevent_possibly_delete_survey_notes() {
           remove_action( 'admin_init', array( 'Automattic\W\A\N\Notes', 'possibly_delete_survey_notes' ), PHP_INT_MAX );
       }
       add_action( 'admin_init', 'prevent_possibly_delete_survey_notes' );
       ```
   
 *  Thread Starter [diegpl](https://wordpress.org/support/users/diegpl/)
 * (@diegpl)
 * [3 years ago](https://wordpress.org/support/topic/query-wc_admin_notes-table-everywhere/#post-16792502)
 * Just if I comment this lines in Notes.php some of the not needed queries are 
   gone:
 *     ```wp-block-code
       	public static function init() {
       		//add_action( 'admin_init', array( __CLASS__, 'schedule_unsnooze_notes' ) );
       		//add_action( 'admin_init', array( __CLASS__, 'possibly_delete_survey_notes' ) );
       		//add_action( 'update_option_woocommerce_show_marketplace_suggestions', array( __CLASS__, 'possibly_delete_marketing_notes' ), 10, 2 );
       	}
       ```
   
 *  Thread Starter [diegpl](https://wordpress.org/support/users/diegpl/)
 * (@diegpl)
 * [3 years ago](https://wordpress.org/support/topic/query-wc_admin_notes-table-everywhere/#post-16792515)
 * Some other not needed queries I prevented commenting these lines in woocommerce/
   src/Internal/Admin/Notes/WooSubscriptionsNotes.php line 39
 *     ```wp-block-code
       public function __construct() {
       		//add_action( 'admin_init', array( $this, 'admin_init' ) );
       		//add_action( 'update_option_woocommerce_helper_data', array( $this, 'update_option_woocommerce_helper_data' ), 10, 2 );
       	}
       ```
   
 *  [Narmeen Mohammed](https://wordpress.org/support/users/narmeen1it/)
 * (@narmeen1it)
 * [3 years ago](https://wordpress.org/support/topic/query-wc_admin_notes-table-everywhere/#post-16793029)
 * If you want to stop a specific database query that is being executed on every
   page of the WordPress Multisite backend, you can use the posts_request filter
   to modify or prevent the query from running. Here’s an example of how you can
   achieve this:
 *     ```wp-block-code
       <span style="font-size: 12.8px;">function stop_specific_query($request, $query) {
           global $wpdb;
   
           // Modify the condition based on your specific query
           if (strpos($query->request, 'your_table_name') !== false) {
               $request = ''; // Empty the query request to prevent it from running
           }
   
           return $request;
       }
       add_filter('posts_request', 'stop_specific_query', 10, 2);
       </span>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Query wc_admin_notes table everywhere’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Narmeen Mohammed](https://wordpress.org/support/users/narmeen1it/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/query-wc_admin_notes-table-everywhere/#post-16793029)
 * Status: resolved