0
点赞
收藏
分享

微信扫一扫

GBase 8c索引设计规范

冶炼厂小练 2022-04-26 阅读 64
  1. GBase 8c提供的 index 类型:B-tree,Hash,GiST (Generalized Search Tree),SP-GiST (space-partitioned GiST),GIN (Generalized Inverted Index), BRIN (Block Range Index),目前不建议使用 Hash索引,通常情况下使用 B-tree。
  2. 建议 create 或 drop index 时,加 CONCURRENTLY 参数,达到与写入数据并发的效果。
  3. 建议对于频繁 update, delete 的包含于 index 定义中的 column的table, 用 create index CONCURRENTLY,drop index CONCURRENTLY 的方式进行维护其对应 index。
  4. 建议用 unique index 代替 unique constraints,便于后续维护。
  5. 建议对 where 中带多个字段 and 条件的高频 query,参考数据分布情况,建多个字段的联合 index。
  6. 建议对固定条件的(一般有特定业务含义)且选择比好(数据占比低)的 query,建带 where的Partial Indexes。

select * from test where status=1 and col=?; -- 其中status=1为固定的条件

create index on test (col) where status=1;

     7.建议对经常使用表达式作为查询条件的 query,可以使用表达式或函数索引加速 query。

select * from test where exp(xxx);

create index on test ( exp(xxx) );  

    8.建议不要建过多index,一般不要超过6个,核心 table(产品,订单)可适当增加 index 个数。

举报

相关推荐

GBase 8c 命名规范

MySQL索引设计规范

GBase 8c管理平台

浅谈GBase 8c灰度发布

GBase 8c AMT属性选项

0 条评论