您好,登錄后才能下訂單哦!
如同翻譯的那樣,Mroonga是一個適用于MySQL的存儲引擎。它為所有MySQL用戶提供了快速的全文搜索功能。
這里直接演示怎么在MariaDB上啟用mroonga存儲引擎
1)加載mroonga插件
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;
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)胡亂插入一些數據
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)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。