0

多数の重複行を持つテーブルがあり、大きすぎるため、BLOB フィールドに一意の値を作成できません。

BLOB フィールド (回答) が重複している重複行を見つけて削除するにはどうすればよいですか?

これはテーブル構造です:

CREATE TABLE `answers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_question` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `answer` blob NOT NULL,
  `language` varchar(2) NOT NULL,
  `datetime` datetime NOT NULL,
  `enabled` int(11) NOT NULL DEFAULT '0',
  `deleted` int(11) NOT NULL DEFAULT '0',
  `spam` int(11) NOT NULL DEFAULT '0',
  `correct` int(11) NOT NULL DEFAULT '0',
  `notification_send` int(11) NOT NULL DEFAULT '0',
  `correct_notification` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `id_question` (`id_question`),
  KEY `id_user` (`id_user`),
  KEY `enabled` (`enabled`)
) ENGINE=InnoDB AUTO_INCREMENT=1488 DEFAULT CHARSET=utf8mb4 
4

1 に答える 1

1

おそらく、列の接頭辞を使用しsubstr() or left()て比較できます。必要なサイズは、データの分布または列データのプレフィックスの一意性によって異なります。一意性チェックのために、以下のクエリを起動できます

select count(distinct left(answer, 128))/count(*), count(distinct left(answer, 256))/count(*) from answers. 

これにより、列の選択性またはデータ分散が提供されます。128 の答えが 1 であると仮定i.e. all unique if you take first 128 bytesし、各行からその量のデータを選択して作業します。それが役に立てば幸い。

于 2013-07-07T11:30:41.443 に答える