From what I can see, there are 2 unique keys, one composite key on the first 3 columns and one on all 4 columns.
What is the purpose of this 2nd unique key?
I am trying to use mysql replication and my logs are full of this message: The important part is “INSERT… ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe”
[Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.
INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe Statement: INSERT INTO wp_post_views (id, type, period, count)
VALUES (264430, 1, '201851', 1)
ON DUPLICATE KEY UPDATE count = count + 1
Can we safely delete this 2nd index? Or make it non unique ?
I can’t see how it is being used.
-
This reply was modified 7 years, 5 months ago by
superlapin.
-
This reply was modified 7 years, 5 months ago by
superlapin.
-
This reply was modified 7 years, 5 months ago by
superlapin.
That’s odd; in my database, id, type & period are all set as primary and index keys, count is just an index key. You can’t have more than one primary key in a table. Moreover a field that is set as a primary key cannot have duplicate values. This table doesn’t have any unique values. It’s poorly designed. IMHO the column ID should be renamed post_id because those values are the posts ID from wp_posts table and then the table should have its own unique ID for each entry and this should be the primary key. This then allows database queries to run correctly and without errors.
Some input from the developer wouldn’t go amiss but they’re clearly not taking this seriously which is a pity.