I ran the following query on the host_groups table:
select hostid, groupid, COUNT(*) AS dupes from hosts_groups group by hostid, groupid HAVING dupes > 1 ORDER BY dupes DESC;
It resulted in:
+--------+---------+-------+
| hostid | groupid | dupes |
+--------+---------+-------+
| 14370 | 1 | 129 |
+--------+---------+-------+
I now understand why creating the unique index is failing, but I don't understand why there are 129 duplicated entries for this groupid/hostid combination.
It all comes down to one template with id 14370 in the group named Templates with id 1. I'm not sure if simply dropping 128 of these entries (leaving me with one unique) will solve this issue and not bring up other issues in other tables
select hostid, groupid, COUNT(*) AS dupes from hosts_groups group by hostid, groupid HAVING dupes > 1 ORDER BY dupes DESC;
It resulted in:
+--------+---------+-------+
| hostid | groupid | dupes |
+--------+---------+-------+
| 14370 | 1 | 129 |
+--------+---------+-------+
I now understand why creating the unique index is failing, but I don't understand why there are 129 duplicated entries for this groupid/hostid combination.
It all comes down to one template with id 14370 in the group named Templates with id 1. I'm not sure if simply dropping 128 of these entries (leaving me with one unique) will solve this issue and not bring up other issues in other tables


Comment