如同翻譯的那樣,Mroonga是一個(gè)適用于MySQL的存儲(chǔ)引擎。它為所有MySQL用戶提供了快速的全文搜索功能。
目前成都創(chuàng)新互聯(lián)公司已為近1000家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)絡(luò)空間、網(wǎng)站托管、服務(wù)器租用、企業(yè)網(wǎng)站設(shè)計(jì)、青岡網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。
這里直接演示怎么在MariaDB上啟用mroonga存儲(chǔ)引擎
1)加載mroonga插件
MariaDB [(none)]>INSTALL SONAME 'ha_mroonga';
MariaDB [(none)]>CREATE FUNCTION last_insert_grn_id RETURNS INTEGER SONAME 'ha_mroonga.so';
2)建表測(cè)試一下
MariaDB [(none)]>create database jerry;
MariaDB [(none)]>use jerry
MariaDB [jerry]> create table t1 (id int not null,name varchar(100)not null,notes text,fulltext index(notes))engine=mroonga;
3)胡亂插入一些數(shù)據(jù)
MariaDB [jerry]> insert into t1 values(1,'擦擦擦','我也不會(huì)告訴你');
Query OK, 1 row affected (0.00 sec)
MariaDB [jerry]> insert into t1 values(2,'啦啦啦','我也不會(huì)告訴你');
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,'王思聰','王爸爸聯(lián)合大森馬跨境電商有限公司');
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 | 王思聰 | 王爸爸聯(lián)合大森馬跨境電商有限公司 |
+----+-----------+--------------------------------------------------+
2 rows in set (0.00 sec)
5 ) 通過執(zhí)行計(jì)劃我們可以看到已經(jīng)用到notes這個(gè)全文索引,并且只需要掃描一行
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)