iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >MariaDB10.2.6启用Mroonga存储引擎用于全文索引
  • 335
分享到

MariaDB10.2.6启用Mroonga存储引擎用于全文索引

2024-04-02 19:04:59 335人浏览 泡泡鱼
摘要

如同翻译的那样,Mroonga是一个适用于Mysql的存储引擎。它为所有mysql用户提供了快速的全文搜索功能。这里直接演示怎么在MariaDB上启用mroonga存储引擎1)加载mroonga插件Mari

如同翻译的那样,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)




您可能感兴趣的文档:

--结束END--

本文标题: MariaDB10.2.6启用Mroonga存储引擎用于全文索引

本文链接: https://www.lsjlt.com/news/43058.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作