From: 谭忠涛 <zhongtao.tan@seaboxdata.com>
To: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Subject: Performance Issue when using gin index
Date: Tue, 21 Jan 2025 10:30:24 +0800
Message-ID: <tencent_7773A0055A04795D1E3DB6E3@qq.com> (raw)
The performance of creating a gin index before inserting data is different from that of inserting data after creating a gin index.
Case:
-- first make pg_trgm
create extension pg_trgm;
create table t1(a int, b varchar(20));
create index t1_b on t1 using gin(b gin_trgm_ops);
insert into t1 select a, a || substr('abcdefg', (random()*100000)::int%10000, 10) || a from generate_series(1,100000) t(a);
analyze t1;
explain analyze select * from t1 where b like '%abc%'; -- slow
reindex index t1_b;
explain analyze select * from t1 where b like '%abc%'; -- normal
Regards
谭忠涛 数据研究院数据库事业部
北京东方金信科技股份有限公司
地址:海淀区知春路7号致真大厦 D 座 14 层
路线:地铁10号线-西土城站-A口
手机:13920129934
公众号:东方金信
网址:www.seaboxdata.com
关于东方金信
北京东方金信科技股份有限公司成立于2013年2月。公司拥有ISO9001、 ISO27001和CMMI5级认证;中国大数据企业50强;首批通过工信部数据中心联盟大数据基础能力和性能双认证;首个国家信息中心“数据资产研究中心”授牌单位;全国信标委智慧城市及大数据标准工作组成员,2017年入选Gartner全球大数据行业和人工智能报告;2019年与腾讯云成为战略合作伙伴并获腾讯数亿元投资;2020年获中金、海淀区国资委入股。
Attachments:
15C04723@CBD93456.C0068F6700000000.png (application/octet-stream, 232.3K) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: zhongtao.tan@seaboxdata.com, pgsql-bugs@lists.postgresql.org
Subject: Re: Performance Issue when using gin index
In-Reply-To: <tencent_7773A0055A04795D1E3DB6E3@qq.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox