MariaDB10.2.6啟用Mroonga儲存引擎用於全文索引

來源:互聯網
上載者:User

標籤:mysql

如同翻譯的那樣,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)




本文出自 “營運人生” 部落格,請務必保留此出處http://jinyan2049.blog.51cto.com/881440/1942333

MariaDB10.2.6啟用Mroonga儲存引擎用於全文索引

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.