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会把索引和依赖索引的对象全部删除
postgresql索引相关推荐
- postgresql索引_PostgreSQL中的索引— 10(Bloom)
postgresql索引 indexing engine and the interface of access methods, as well as 索引引擎和访问方法的接口,以及hash ind ...
- PostgreSQL索引膨胀
PostgreSQL索引膨胀 最后编辑时间:2022年1月23日00:07:27 通常是因为数据乱序写入导致的,索引页中的数据是有序的,而索引字段乱序写入,会导致索引频繁分裂,使得索引页并不是百分百填 ...
- postgresql索引_PostgreSQL中的索引— 8(RUM)
postgresql索引 indexing engine, the interface of access methods, and main access methods, such as: 索引引 ...
- postgresql索引_PostgreSQL中的索引— 6(SP-GiST)
postgresql索引 indexing engine, 索引引擎 , the interface of access methods, and three methods: 访问方法的接口以及三种 ...
- PostgreSQL索引介绍
梦中彩虹 博客园 首页 新随笔 联系 管理 随笔 - 131 文章 - 1 评论 - 14 PostgreSQL索引介绍 INDEX 索引是增强数据库性能的常用方法.索引使得数据库在查找和检索数据 ...
- 掌握查询利器 深入理解PostgreSQL索引原理与优化
文章目录 一.前言 1.1 PostgreSQL索引的重要性 1.2 本文的结构和目的 二.索引概述 2.1 什么是索引 2.2 为什么要使用索引 2.3 索引如何工作 三.索引类型 3.1 B-tr ...
- PostgreSQL索引页
本页目的,是起到索引其他所有本人所写文档的作用: 分类一:PostgreSQL基础知识与基本操作-------------------- PostgreSQL基础知识与基本操作索引页 分类二:Pos ...
- postgresql 索引状态_PostgreSQL中的锁:3.其他锁
我们已经讨论了一些对象级锁(特别是关系级锁),以及行级锁及其与对象级锁的连接,还探讨了等待队列.这次我们要来个大杂烩.我们将从死锁开始(实际上,我计划上次讨论死锁,但是这篇文章本身篇幅太长了),然后简 ...
- postgresql 索引使用参考
通常在postgresql创建普通索引如下 create index idx_table_name_x1 on table_name(col_name); reate index 执行后在创建索引期间 ...
- PostgreSQL索引(一)
索引的作用:帮你快速的查询数据 索引的缺点: 你如果把这个东西设置为索引,那么就意味着你的这个表的数据的增删改效率都会变低 索引需要占空间 对于索引数据的每个操作,无论是插入.删除还是更新表行,该表的 ...
最新文章
- 2021年大数据Flink(二十三):​​​​​​​Watermaker案例演示
- 三流Java搞技术,二流Java搞框架,一流Java…
- 移动端事件 、zepto移动端事件
- JAVA取数两个数组交集,考虑重复和不重复元素
- 返璞归真的Open×××的p2p模式
- android社会化分享
- 【C++ Priemr | 15】虚函数常见问题
- 神经网络与深度学习——TensorFlow2.0实战(笔记)(四)(python模块、包和库)
- Jenkins-Pipeline 流水线发布
- springboot热部署之spring-boot-devtools
- 解决办法:ImportError: No module named pycuda.driver
- while循环--登录
- 在linux服务器上安装jdk
- 鲲鹏开发者技术峰会·福州圆满落幕!
- AD14中自定义PCB板形状
- 网上传说软件测试培训真的那么黑心吗?都是骗局?
- 快速制作index.html,介绍一个h5快速制作平台鲁班H5
- JavaScript:实现返回格式化的电话号码的字符串算法(附完整源码)
- sourceinsight常用宏
- 单片机消抖c语言程序,基于单片机定时器软件消抖C51程序研究
热门文章
- k8s部署jar包_K8S部署SpringBoot应用_都超的博客-CSDN博客_k8s springboot
- hmm 求隐藏序列_自然语言处理(3)隐马尔科夫模型 HMM
- php接收不到url传值_【干货】PHP 异步后台处理
- Eclipse用法和技巧十二:快速复制一行
- Android仿人人客户端(v5.7.1)——新鲜事之下拉列表(过滤项列表)
- myeclipse下使用Junit4进行单元测试
- 《Android Property
- Android Studio 解决 Cannot resolve symbol xxx 添加依赖后出现飘红
- java怎么写自定义布局_java-Android设置自定义首选项布局
- Web容器初始化过程