MySQL Full-text Search Workaround for innoDB tables

前端 未结 5 976
小鲜肉
小鲜肉 2020-12-05 01:15

I\'m designing an internal web application that uses MySQL as its backend database. The integrity of the data is crucial, so I am using the innoDB engine for i

5条回答
  •  我在风中等你
    2020-12-05 01:53

    I think its truly awkward. That said, my "quick prototype that will probably accidentally become production code" method of doing this is something like this:

    CREATE TEMPORARY TABLE search_mirror (FULLTEXT INDEX (col1, col2, ...)) Engine=MyISAM SELECT * FROM original_innodb_table;
    
    SELECT * FROM search_mirror WHERE MATCH(col1, col2, ...) AGAINST ('foo');
    
    DROP TEMPORARY TABLE search_mirror;
    

    And for bonus points you could do all of that inside a transaction should that suit your fancy (double bonus if you're using non-persistent connections and only searching once per connect, as you can then eliminate the drop statement).

    Yes I realize that this is not true mirroring/replication. Yes I realize duping the table can be expensive (relatively small datasets here). Like I said, quick and dirty prototype. YMMV

提交回复
热议问题