Database over 1000MB

[ad_1]

Hi all,

I have a WordPress site that has a database around 1.1GB in size. After a while looking at the DB it seems two tables are taking up 900MB:

wp_inbound_tracked_links and it's backup through Vaultpress.

Wondering if anyone has any advice as to how to clean this up? As it seems relatively insane and means I can't downgrade hosting plans.

Couldn't find anything useful when googling it so trying here!

[ad_2]
3 Comments
  1. That is pretty crazy. That wp_inbound_tracked_links appears to come from a plugin called Inbound Leads, according to [https://wphive.com/plugins/leads/](https://wphive.com/plugins/leads/) – so it’d be worth reaching out to them.

    What’s the other table? wp_postmeta?

  2. Backup site, go to phpMyAdmin, navigate to table, click on operations tab, then click through red ‘empty table (truncate)’.

    You may need to compact the table and force cpanel to recalculate the mysql database as its not instant

  3. Have you managed this site from the start? It’s very possible the plugin mentioned by u/bluesix was setup by the *first* *person* trying to build the WP site.

    I have this snippet I use sometimes to get more info on weird tables in the db… I modified it a bit for your use-case. Since it’s an admin-ajax action, it shouldn’t affect your front-end.

    This code does the following:

    1. Retrieves the latest 10 rows from the “wp_inbound_tracked_links” table.
    2. Fetches the table size in MB.
    3. Counts the total number of rows in the table.
    4. Gets the date of the oldest record.
    5. Gets the date of the newest record.

    After adding it to your function.php, just visit `/wp-admin/admin-ajax.php?action=get_latest_tracked_links`

    You can paste the JSON results in an online formatter for easier reading if you don’t have a browser add-on for this. My thinking is that **if no record has been added into the DB in a long time**, just rename/export/backup the table and drop it from the db.

    <?php
    // Add this to your theme’s functions.php or a custom plugin file
    // Results at: /wp-admin/admin-ajax.php?action=get_latest_tracked_links

    // Register the AJAX action
    add_action(‘wp_ajax_get_latest_tracked_links’, ‘get_latest_tracked_links’);
    add_action(‘wp_ajax_nopriv_get_latest_tracked_links’, ‘get_latest_tracked_links’);

    function get_latest_tracked_links() {
    global $wpdb;
    $table_name = $wpdb->prefix . ‘inbound_tracked_links’;

    // Get the latest 10 rows
    $query = “SELECT * FROM $table_name ORDER BY id DESC LIMIT 10”;
    $results = $wpdb->get_results($query, ARRAY_A);

    // Get additional diagnostic information
    $table_size_query = $wpdb->prepare(“SELECT table_name AS ‘Table’, round(((data_length + index_length) / 1024 / 1024), 2) AS ‘Size in MB’ FROM information_schema.TABLES WHERE table_schema = %s AND table_name = %s”, DB_NAME, $table_name);
    $table_size = $wpdb->get_row($table_size_query);

    $total_rows_query = “SELECT COUNT(*) FROM $table_name”;
    $total_rows = $wpdb->get_var($total_rows_query);

    $oldest_record_query = “SELECT MIN(created) FROM $table_name”;
    $oldest_record_date = $wpdb->get_var($oldest_record_query);

    $newest_record_query = “SELECT MAX(created) FROM $table_name”;
    $newest_record_date = $wpdb->get_var($newest_record_query);

    $response = array(
    ‘latest_rows’ => $results,
    ‘table_size_mb’ => $table_size->{‘Size in MB’},
    ‘total_rows’ => $total_rows,
    ‘oldest_record_date’ => $oldest_record_date,
    ‘newest_record_date’ => $newest_record_date
    );

    wp_send_json($response);
    }

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer