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会把索引和依赖索引的对象全部删除

postgresql索引相关推荐

  1. postgresql索引_PostgreSQL中的索引— 10(Bloom)

    postgresql索引 indexing engine and the interface of access methods, as well as 索引引擎和访问方法的接口,以及hash ind ...

  2. PostgreSQL索引膨胀

    PostgreSQL索引膨胀 最后编辑时间:2022年1月23日00:07:27 通常是因为数据乱序写入导致的,索引页中的数据是有序的,而索引字段乱序写入,会导致索引频繁分裂,使得索引页并不是百分百填 ...

  3. postgresql索引_PostgreSQL中的索引— 8(RUM)

    postgresql索引 indexing engine, the interface of access methods, and main access methods, such as: 索引引 ...

  4. postgresql索引_PostgreSQL中的索引— 6(SP-GiST)

    postgresql索引 indexing engine, 索引引擎 , the interface of access methods, and three methods: 访问方法的接口以及三种 ...

  5. PostgreSQL索引介绍

    梦中彩虹 博客园 首页 新随笔 联系 管理 随笔 - 131  文章 - 1  评论 - 14 PostgreSQL索引介绍 INDEX 索引是增强数据库性能的常用方法.索引使得数据库在查找和检索数据 ...

  6. 掌握查询利器 深入理解PostgreSQL索引原理与优化

    文章目录 一.前言 1.1 PostgreSQL索引的重要性 1.2 本文的结构和目的 二.索引概述 2.1 什么是索引 2.2 为什么要使用索引 2.3 索引如何工作 三.索引类型 3.1 B-tr ...

  7. PostgreSQL索引页

    本页目的,是起到索引其他所有本人所写文档的作用: 分类一:PostgreSQL基础知识与基本操作--------------------  PostgreSQL基础知识与基本操作索引页 分类二:Pos ...

  8. postgresql 索引状态_PostgreSQL中的锁:3.其他锁

    我们已经讨论了一些对象级锁(特别是关系级锁),以及行级锁及其与对象级锁的连接,还探讨了等待队列.这次我们要来个大杂烩.我们将从死锁开始(实际上,我计划上次讨论死锁,但是这篇文章本身篇幅太长了),然后简 ...

  9. postgresql 索引使用参考

    通常在postgresql创建普通索引如下 create index idx_table_name_x1 on table_name(col_name); reate index 执行后在创建索引期间 ...

  10. PostgreSQL索引(一)

    索引的作用:帮你快速的查询数据 索引的缺点: 你如果把这个东西设置为索引,那么就意味着你的这个表的数据的增删改效率都会变低 索引需要占空间 对于索引数据的每个操作,无论是插入.删除还是更新表行,该表的 ...

最新文章

  1. 2021年大数据Flink(二十三):​​​​​​​Watermaker案例演示
  2. 三流Java搞技术,二流Java搞框架,一流Java…
  3. 移动端事件 、zepto移动端事件
  4. JAVA取数两个数组交集,考虑重复和不重复元素
  5. 返璞归真的Open×××的p2p模式
  6. android社会化分享
  7. 【C++ Priemr | 15】虚函数常见问题
  8. 神经网络与深度学习——TensorFlow2.0实战(笔记)(四)(python模块、包和库)
  9. Jenkins-Pipeline 流水线发布
  10. springboot热部署之spring-boot-devtools
  11. 解决办法:ImportError: No module named pycuda.driver
  12. while循环--登录
  13. 在linux服务器上安装jdk
  14. 鲲鹏开发者技术峰会·福州圆满落幕!
  15. AD14中自定义PCB板形状
  16. 网上传说软件测试培训真的那么黑心吗?都是骗局?
  17. 快速制作index.html,介绍一个h5快速制作平台鲁班H5
  18. JavaScript:实现返回格式化的电话号码的字符串算法(附完整源码)
  19. sourceinsight常用宏
  20. 单片机消抖c语言程序,基于单片机定时器软件消抖C51程序研究

热门文章

  1. k8s部署jar包_K8S部署SpringBoot应用_都超的博客-CSDN博客_k8s springboot
  2. hmm 求隐藏序列_自然语言处理(3)隐马尔科夫模型 HMM
  3. php接收不到url传值_【干货】PHP 异步后台处理
  4. Eclipse用法和技巧十二:快速复制一行
  5. Android仿人人客户端(v5.7.1)——新鲜事之下拉列表(过滤项列表)
  6. myeclipse下使用Junit4进行单元测试
  7. 《Android Property
  8. Android Studio 解决 Cannot resolve symbol xxx 添加依赖后出现飘红
  9. java怎么写自定义布局_java-Android设置自定义首选项布局
  10. Web容器初始化过程