zoukankan      html  css  js  c++  java
  • postgresql 索引

    1、B-tree索引

    create index idx_contacts_name on contacts(name);

    2、数组索引

    create index idx_contacts_phone on contacts using gin(phone);

    注:phone在contacts表中是一个数组类型

    3、降序索引

    create index idx_contacts_name on contacts(name desc);

    4、指定存储参数

    create index idx_contacts_name on contacts(name) with(fillfactor=50);

    注:fillfactor是常用的存储参数

    5、指定空值排在前面

    create index idx_contacts_name on contacts(name desc nulls first);

    6、避免创建索引的长时间阻塞,可以在index关键字后面增加concurrently关键字,可以减少索引的阻塞时间

    create index concurrently idx_contacts_name on contacts(name desc);

    注意,重建索引时不支持concurrently ,可以新建一个索引,然后删除旧索引,另外并发索引被强制取消,可能会留下无效索引,这个索引将会导致更新变慢,如果是唯一索引,还会导致插入重复值失败。

    7、修改索引

    索引重命名:alter index name rename to new_name;

    设置表空间:alter index name set tablespace tablespace_name;

    设置存储参数:alter index name set(storage_parameter=value[,...])

    重设存储参数:alter index name reset(storeage_parameter[,...])

    8、删除索引

    drop index if exists idx_contacts_name_old;

    8、cascade会把索引和依赖索引的对象全部删除

  • 相关阅读:
    通过通过url routing解决UIViewController跳转依赖
    vs2010下配置CUDA出现kernel launch failed问题,内核无效
    ganglia监控自己定义metric实践
    faq
    Android进阶图片处理之三级缓存方案
    操作系统 内存管理(一)
    rocketmq消费队列代码
    网页固定側栏的做法
    web爬虫之登录google paly 商店
    C之内存地址
  • 原文地址:https://www.cnblogs.com/xiaofoyuan/p/5264044.html
Copyright © 2011-2022 走看看