Primoz Cigler on Business and Code

WordPress MySQL database size growing because of the Ninja Forms’ tables

The other day I was checking one of the WordPress websites I own and noticed that the mysql database has drastically grown recently. After doing some investigation I found out that two tables are taking up about 95% of the space.

The two probleatic tables were wp_nf3_objects and wp_nf3_object_meta which belong to a popular Ninja Forms plugin that I use. After doing some research I figured that these two tables contain only the logs of the sql queries and PHP file traces. Checking the code of the plugin, it was apparent that the logging cannot be disabled by some settings but it should be disabled by code.

In case that you had the same issue with the Ninja Forms tables growing large in size, here is the code snippet that you can paste in your theme’s functions.php file:

/**
 * Remove Ninja Forms logging
 */
if ( function_exists( 'Ninja_Forms' ) ) {
  remove_filter( 'query', array( Ninja_Forms(), 'log_postmeta_query' ) );
}

This code snippet stopped logging the mysql queries and trances and therefore solved the issues for me. After a few days, everything still works normally and the size of the WordPress database is back to normal (after deleting all the records from these two tables).

You should follow me on twitter, here.

Author

Primoz

A software engineer transitioning to a digital marketer and entrepreneur. Walking the talk. Windsurfer, digital nomad.