Mysql不返回数据,但数据存在

时间:2015-01-13 09:29:50

标签: mysql tokudb

今天非常奇怪的问题。 查询就像基本数学一样简单:

MariaDB [betradar]> select id,id_event,id_bookmaker  from event_outcome where id like '%16069689%';
+----------+----------+--------------+
| id       | id_event | id_bookmaker |
+----------+----------+--------------+
| 16069689 |    11198 |           14 |
+----------+----------+--------------+

但是这个让我发疯:

MariaDB [betradar]> select id,id_event  from event_outcome where id=16069689;
Empty set (0.00 sec)

即:虽然数据就在那里,但选择不会返回任何数据。这是与群集密钥相关的问题吗? 我的表:

 CREATE TABLE `event_outcome` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `id_event` int(11) unsigned NOT NULL,
  `id_outcome` int(11) unsigned NOT NULL,
  `id_bookmaker` int(11) unsigned NOT NULL,
  `outcome_type` varchar(50) DEFAULT NULL ,
  `quotation` decimal(10,2) NOT NULL,
  `quotation_datetime` datetime DEFAULT NULL,
  `is_last` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0',
  `create_time` int(11) DEFAULT '0',
  `update_time` int(11) DEFAULT '0',
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `mp_read` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_event` (`id_event`),
  KEY `idx_outcome` (`id_outcome`),
  KEY `idx_bookmaker` (`id_bookmaker`),
  KEY `idx_is_last` (`is_last`),
  KEY `idx_outcome_type` (`outcome_type`),
  KEY `clstr_event` (`id_event`,`id_outcome`,`id_bookmaker`,`is_last`,`mp_read`) `clustering`=yes
) ENGINE=TokuDB AUTO_INCREMENT=16632394 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT `compression`='tokudb_zlib'

1 个答案:

答案 0 :(得分:0)

我不明白你的原始查询,为什么你会有一个WHERE子句并匹配一个类似表达式的int?

如果您想查看群集索引是否存在问题,您有两个选择:

  • 删除它,然后重新运行查询
  • 强制两个查询都使用带有index hint
  • 的PK索引