在事务中使用match / against时,它似乎不会从临时的未提交数据中查询:
start transaction;
insert into feed_full_text (feed_id, full_text) values (5000008, "lorem ipsum");
select feed_id, full_text
from feed_full_text
where feed_id = 5000008 and match(full_text) against("lorem" in boolean mode)
order by feed_id desc
limit 1;
commit
但不会返回结果:
start transaction;
insert into feed_full_text (feed_id, full_text) values (5000008, "lorem ipsum");
select feed_id, full_text
from feed_full_text
where feed_id = 5000008
order by feed_id desc
limit 1;
commit
返回刚刚插入的行,并且:
insert into feed_full_text (feed_id, full_text) values (5000008, "lorem ipsum");
select feed_id, full_text
from feed_full_text
where feed_id = 5000008 and match(full_text) against("lorem" in boolean mode)
order by feed_id desc
limit 1;
也返回行。这是一个错误还是我错过了什么?我使用5.7.11支持InnoDB中的全文索引。
答案 0 :(得分:2)
这是预期的行为。 documentation说:
InnoDB全文索引交易处理 由于其缓存和批处理行为,InnoDB FULLTEXT索引具有特殊的事务处理特性。具体来说,FULLTEXT索引的更新和插入在事务提交时处理,这意味着FULLTEXT搜索只能看到已提交的数据。