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索引锁
最近客户在使用我司开发的数据库时,报告了如下问题(也不能算是问题,就是疑惑吧),环境如下: OS : Red Hat Enterprise Linux Server release 6.7 (Sant ...
- PostgreSQL索引描述
索引方式:唯一索引,主键索引,多属性索引,部分索引,表达式索引. 索引类型:B-Tree,Hash,GiST,GIN以及表达式索引 PostgreSQL所有索引都是“从属索引”,也就是说,索引在物理上 ...
- PostgreSQL索引页
磨砺技术珠矶,践行数据之道,追求卓越价值 [作者 高健@博客园 luckyjackgao@gmail.com] 本页目的,是起到索引其他所有本人所写文档的作用: 分类一:PostgreSQL基础 ...
- PostgreSQL索引介绍
h1, h2, h3, h4, h5, h6, p, blockquote { margin: 5px; padding: 5; } body { font-family: "Helveti ...
- PostgreSQL 索引坏块处理
今天应用反应有张表查询报错,报错信息如下 back=# select max(create_time) from public.tbl_index_table where create_time> ...
- PostgreSQL索引思考
当在看Monetdb列存行只支持IMPRINTS和ORDERED这两种索引,且只支持定长数值类型时,就在思考,对于列存,还有必要建索引吗?在PostgreSQL的索引就要灵活很多,我对常用列建合理的索 ...
- PostgreSQL 索引膨胀
索引膨胀,主要针对B-tree而言 索引膨胀的几个来源: 大量删除发生后,导致索引页面稀疏,降低了索引的使用效率: PG9.0之前的版本,vacuum full会同样导致索引页面稀疏: 长时间运行的事 ...
- PostgreSQL内部结构与源代码研究索引页
磨砺技术珠矶,践行数据之道,追求卓越价值 luckyjackgao@gmail.com 返回顶级页:PostgreSQL索引页 本页记录所有本人所写的PostgreSQL的内部结构和源代码研究相关文摘 ...
- PostgreSQL基础知识与基本操作索引页
磨砺技术珠矶,践行数据之道,追求卓越价值 返回顶级页:PostgreSQL索引页 luckyjackgao@gmail.com 本页记录所有本人所写的PostgreSQL的基础知识和基本操作相关文摘和 ...
随机推荐
- UI事件 计算器界面
1.MainActivity.java package com.example.administrator.testapp2; import android.support.v7.app.AppCom ...
- CodeForces 131A cAPS lOCK
cAPS lOCK Time Limit:500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit St ...
- c#中struct和class的区别 详细[转]
转自:http://blog.csdn.net/justlovepro/archive/2007/11/02/1863734.aspx 有这么几点不同: 1.struct 是值类型,class是对象类 ...
- LuaTinker的bug和缺陷
LuaTinker的bug和缺陷 LuaTinker是一套还不错的C++代码和Lua代码的绑定库,作者是韩国人Kwon-il Lee,作者应该是参考了LuaBind后,为了简化和避免过重而实现的.其官 ...
- 【转载】COM:IUnknown、IClassFactory、IDispatch
原文:COM:IUnknown.IClassFactory.IDispatch COM组件有三个最基本的接口类,分别是IUnknown.IClassFactory.IDispatch. COM规范规定 ...
- R语言保存文件 Error in save error writing to connection
Error in save(filtered, file = paste(sampleName, "filtered", sep = "_")) : err ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 水
D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- tilemap坐标转换
像素点跟tile的索引之间的转换//从cocos2d-x坐标转换为Tilemap坐标CCPoint GameMap::tileCoordForPosition(CCPoint position){ i ...
- JavaScript删除-confirm
一> onclick="javascript:if (confirm('您确定要删除吗?注意:此操作不可恢复,请谨慎操作!')){return true;} return false; ...
- c++ IO的继承结构
#include <stdio.h> #include <iostream>//cin,cout #include <sstream>//ss transfer. ...