如同翻譯的那樣,Mroonga是一個適用於MySQL的存儲引擎。它爲全部MySQL用戶提供了快速的全文搜索功能。ide
這裏直接演示怎麼在MariaDB上啓用mroonga存儲引擎測試
1)加載mroonga插件spa
MariaDB [(none)]>INSTALL SONAME 'ha_mroonga';插件
MariaDB [(none)]> CREATE FUNCTION last_insert_grn_id RETURNS INTEGER SONAME 'ha_mroonga.so';翻譯
2)建表測試一下索引
MariaDB [(none)]>create database jerry;it
MariaDB [(none)]>use jerryio
MariaDB [jerry]> create table t1 (id int not null,name varchar(100)not null,notes text,fulltext index(notes))engine=mroonga;table
3)胡亂插入一些數據ast
MariaDB [jerry]> insert into t1 values(1,'擦擦擦','我也不會告訴你');
Query OK, 1 row affected (0.00 sec)
MariaDB [jerry]> insert into t1 values(2,'啦啦啦','我也不會告訴你');
Query OK, 1 row affected (0.01 sec)
MariaDB [jerry]> insert into t1 values(3,'dashaba','森馬服飾');
Query OK, 1 row affected (0.00 sec)
MariaDB [jerry]> insert into t1 values(4,'victor','大森馬投資有限公司');
Query OK, 1 row affected (0.00 sec)
MariaDB [jerry]> insert into t1 values(5,'kukumimilulu','森馬跨境電商有限公司');
Query OK, 1 row affected (0.00 sec)
MariaDB [jerry]> insert into t1 values(6,'王思聰','王爸爸聯合大森馬跨境電商有限公司');
Query OK, 1 row affected (0.00 sec)
4)用以下命令查詢
MariaDB [jerry]> select * from t1 where match(notes) against('大森馬' in BOOLEAN MODE);
+----+-----------+--------------------------------------------------+
| id | name | notes |
+----+-----------+--------------------------------------------------+
| 4 | victor | 大森馬投資有限公司 |
| 6 | 王思聰 | 王爸爸聯合大森馬跨境電商有限公司 |
+----+-----------+--------------------------------------------------+
2 rows in set (0.00 sec)
5 ) 經過執行計劃咱們能夠看到已經用到notes這個全文索引,而且只須要掃描一行
MariaDB [jerry]> explain select * from t1 where match(notes) against('大森馬' in BOOLEAN MODE);
+------+-------------+-------+----------+---------------+-------+---------+------+------+-----------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+----------+---------------+-------+---------+------+------+-----------------------------------+
| 1 | SIMPLE | t1 | fulltext | notes | notes | 0 | | 1 | Using where with pushed condition |
+------+-------------+-------+----------+---------------+-------+---------+------+------+-----------------------------------+
1 row in set (0.00 sec)