WordPress.org

Forums

WP Statistics
[resolved] Fix for db error creating Unique index (3 posts)

  1. kitchin
    Member
    Posted 11 months ago #

    When upgrading, you may see an error about duplicate entries making MySQL fail and the upgrade fail (may require WP_DEBUG). The error message cites this command:

    ALTER TABLE wp_statistics_visitor ADD UNIQUE KEY date_ip (last_counter,ip)

    The fix is to get into PHPMyAdmin or a similar tool and execute this SQL statement:

    ALTER IGNORE TABLE wp_statistics_visitor ADD UNIQUE KEY date_ip (last_counter,ip)

    Backup your data first of course. This command will delete duplicate rows from the table. My own table went from 930,270 rows to 865,658 rows.

    I'm assuming 'wp_' is the prefix in my example. Actually, the plugin could do this fix too, but not using dbDelta.

    The upgrade may also run out of memory and that can cause the table needing REPAIR someone else noticed.

    https://wordpress.org/plugins/wp-statistics/

  2. Greg Ross
    Member
    Plugin Author

    Posted 11 months ago #

    The data is actually duplicate information so deleting it is better than ignoring it. I'm going to yank to code out of the upgrade process though, it's causing too many issues. I'll look at a better way to handle it in a future release.

  3. kitchin
    Member
    Posted 11 months ago #

    IGNORE means delete. Odd business, but it's in the MySQL manual for ALTER.
    http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

    There also an IGNORE for INSERT which is similar. And then there is this: http://dev.mysql.com/doc/refman/5.1/en/insert-on-duplicate.html which might even work.

    And in any case, ALTER IGNORE is a good maintenance action. I guess it would work on all WP supported platforms?

Reply

You must log in to post.

About this Plugin

  • WP Statistics
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags