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

  1. kitchin
    Posted 1 year 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.


  2. Greg Ross
    Plugin Author

    Posted 1 year 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
    Posted 1 year ago #

    IGNORE means delete. Odd business, but it's in the MySQL manual for ALTER.

    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?

Topic Closed

This topic has been closed to new replies.

About this Plugin

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

About this Topic