pg_index
在pg11之后,引入了indnkeyatts字段,根据官方文档解释其作用:The number of key columns in the index, not counting any included columns, which are merely stored and do not participate in the index semantics。
第一感觉,和indnatts字段差不多,但两者的说明存在差异。后者是参与索引的列的计数,前者是关键列的计数。
于是做了一个小测试,如下:
新建test表
CREATE TABLE test (
a _int8 NULL,
b _int8 NULL,
c _int8 NULL
);
CREATE INDEX test_a_idx ON test (a);
--单列索引
CREATE INDEX test_a_idx1 ON test (a,b);
--组合索引
CREATE INDEX test_a_idx2 ON test (a,b) include (c);
--使用inclue创建非键列
---查询各个索引的计数
SELECT
indnkeyatts,indnatts,i_c.relname
FROM
pg_index i
JOIN
pg_class c ON c.oid = i.indrelid
JOIN
pg_class i_c ON i_c.oid = i.indexrelid
JOIN
pg_am am ON am.oid = i_c.relam
LEFT JOIN
pg_attribute a ON a.attrelid = c.oid AND a.attnum = ANY(i.indkey)
JOIN
pg_namespace n ON n.oid = c.relnamespace
WHERE
c.relname = 'test'
结果如下
| indnkeyatts | indnatts | relname |
|---|---|---|
| 2 | 3 | test_a_idx2 |
| 2 | 3 | test_a_idx2 |
| 2 | 3 | test_a_idx2 |
| 1 | 1 | test_a_idx |
| 2 | 2 | test_a_idx1 |
| 2 | 2 | test_a_idx1 |
感觉差异就在于对include字段的处理上。不知道还有其他情况,会影响计数的值,有了解的可以留言讨论下。
pg_index的更多相关文章
- PG CREATEINDEX CONCURRENTLY
PG CREATEINDEX CONCURRENTLY [TOC] 官方说法 根据9.1的文档 Creating an index can interfere with regular operati ...
- Greenplum获取表结构
最近在折腾greenplum,遇到一个蛋疼的问题,那就是获取表结构,也就是建表语句.大家都知道在MySQL里面是非常easy的,show create table table_name 就搞定了,在g ...
- 使用pgstatspack分析PostgreSQL数据库性能
pgstatspack [root@test01 soft]# wget http://pgfoundry.org/frs/download.php/3151/pgstatspack_version_ ...
- PostgreSQL auto_explain
The auto_explain module provides a means for logging execution plans of slow statements automaticall ...
- PG sys function
The System Catalogs of PostgreSQLscott=# \dS List of relations Schema | Name | Type | Owner -------- ...
- PostgreSQL9.1 upgrade to PostgreSQL9.5rc1
PostgreSQL9.1.0 upgrade to PostgreSQL9.5rc1 安装PG9.1端口为5432 [pgup@minion1 pg]$ ls postgresql-9.1.0.ta ...
- PostgreSQL 系统的基本体系结构
PostgreSQL 使用客户机/服务器(C/S)的模式提供服务,一个PostgreSQL会话由下列相关的进程(程序)组成: (1)一个服务器端进程.该进程管理数据库文件,接受客户端与数据库的连接,且 ...
- PostgreSQL and bloat
The bucardo project has released its nagios plugins for PostgreSQL and we can extract from them this ...
- Heap Only Tuples (HOT)
Introduction ------------ The Heap Only Tuple (HOT) feature eliminates redundant index entries and a ...
- Understanding postgresql.conf : log*
After loooong pause, adding next (well, second) post to the “series“. This time, I'd like to describ ...
随机推荐
- 10-30 NOIP模拟赛
10-30 NOIP模拟赛 今天分数还看的过去,只是第二题没有正解,第三题没有35我表示很伤心.必须继续努力,保持内心纯净,心无杂念,知行合一,摒除恶念. 100 + 80 + 5 = 185 芜湖! ...
- 记一次Razor Pages无法编译问题及解决
解决方案写在前面:更新Visual Studio及相关组件,本人版本自17.8.0更新至17.11.4 缘起于公司的一个业务接口,在有一些信息需要在应用内嵌的webview中展示,信息不少,涉及的前端 ...
- 五,MyBatis-Plus 当中的 “ActiveRecord模式”和“SimpleQuery工具类”(详细实操)
五,MyBatis-Plus 当中的 "ActiveRecord模式"和"SimpleQuery工具类"(详细实操) @ 目录 五,MyBatis-Plus 当 ...
- ant-design-vue 登录表单校验
最近刚刚上手了 Vue3 的 antdv ui框架,来做个简单的登录校验练练手 安装 antdv 依赖 npm install ant-design-vue --save 在 main.ts/js 中 ...
- 29. GIL全局解释器锁、信号量、线程池进程池
1. GIL全局解释器锁 1.1 概念 '''In CPython, the global interpreter lock, or GIL, is a mutex that prevents mul ...
- 架构与思维:漫谈高并发业务的CAS及ABA
1 高并发场景下的难题 1.1 典型支付场景 这是最经典的场景.支付过程,要先查询买家的账户余额,然后计算商品价格,最后对买家进行进行扣款,像这类的分布式操作, 如果是并发量低的情况下完全没有问题的, ...
- Xcode 12 引用缺失包:libstdc++.tbd libstdc++.6.tbd libstdc++.6.0.9.tbd引发的一系列问题解析
升级到xcode12后会有libstdc++.tbd libstdc++.6.tbd libstdc++.6.0.9.tbd 等库缺失的情况,并引发一些列的 Undefined symbols for ...
- AWR分享案例
[深度长文]循序渐进解读Oracle AWR性能分析报告 - ORACLE - dbaplus社群:围绕Data.Blockchain.AiOps的企业级专业社群.技术大咖.原创干货,每天精品原创文章 ...
- MIL-STD-1553B总线通信模块(1553B板卡)
MIL-STD-1553B总线通信模块(1553B板卡)产品具有以下特点: 1.产品覆盖多种接口CPCI/PXI/PCI/PC104/PC104+/USB等,满足用户不同平台的使用要求: 2.自主知识 ...
- KubeSphere 社区征稿说明
KubeSphere 社区一直致力于云原生技术的布道工作.通过组织线下 Meetup,线上的定期技术直播,KubeSphere 社区输出了颇多精彩的技术分享内容.此外,社区还产出了多篇优质的技术文章, ...