在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的更多相关文章

  1. PG CREATEINDEX CONCURRENTLY

    PG CREATEINDEX CONCURRENTLY [TOC] 官方说法 根据9.1的文档 Creating an index can interfere with regular operati ...

  2. Greenplum获取表结构

    最近在折腾greenplum,遇到一个蛋疼的问题,那就是获取表结构,也就是建表语句.大家都知道在MySQL里面是非常easy的,show create table table_name 就搞定了,在g ...

  3. 使用pgstatspack分析PostgreSQL数据库性能

    pgstatspack [root@test01 soft]# wget http://pgfoundry.org/frs/download.php/3151/pgstatspack_version_ ...

  4. PostgreSQL auto_explain

    The auto_explain module provides a means for logging execution plans of slow statements automaticall ...

  5. PG sys function

    The System Catalogs of PostgreSQLscott=# \dS List of relations Schema | Name | Type | Owner -------- ...

  6. 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 ...

  7. PostgreSQL 系统的基本体系结构

    PostgreSQL 使用客户机/服务器(C/S)的模式提供服务,一个PostgreSQL会话由下列相关的进程(程序)组成: (1)一个服务器端进程.该进程管理数据库文件,接受客户端与数据库的连接,且 ...

  8. PostgreSQL and bloat

    The bucardo project has released its nagios plugins for PostgreSQL and we can extract from them this ...

  9. Heap Only Tuples (HOT)

    Introduction ------------ The Heap Only Tuple (HOT) feature eliminates redundant index entries and a ...

  10. Understanding postgresql.conf : log*

    After loooong pause, adding next (well, second) post to the “series“. This time, I'd like to describ ...

随机推荐

  1. Azure Computer Vision 之 Smart Crop 智能裁剪图片

    前言 一个网站通常有许多地方会用到同一张图,但是比例又不一样. 一般的做法就是用 CSS 的 cover 和 contain 来处理. 由于 cover 只会保留中间信息, 所以很多时候需要人工裁剪. ...

  2. C++ char*类型与vector类型的相互转换

    char*类型与vector<char> 类型的相互转换 很多时候需要使用动态的字符串,但是char*难以完成相应的扩容操作,而动态数组vector则可以简单地完成,结合二者特性就可以完成 ...

  3. ARM64中的ASID地址空间标识符

    1. 从ARM32到ARM64 从ARM32到ARM64不止将处理器从32位升级到了64位,还有许多性能的技术也得到了极大的提升,光是个头长了可不行啊!能耐也得跟着长啊!哈哈哈 1.1 ARM32的T ...

  4. MobileNet V2中InvertedResidual实现

    1.为了方便理解其本身结构,找到源码理解一下. 2.论文地址:http://arxiv.org/pdf/1801.04381.pdf 3.V2相比较V1增加了倒残差结构和线性瓶颈层.整个结构按照维度来 ...

  5. 0503-autograd实战之线性回归

    0503-autograd实战之线性回归 目录 一.用 variable 实现线性回归(autograd 实战) 二.第五章总结 pytorch完整教程目录:https://www.cnblogs.c ...

  6. HDU-ACM 2024 Day2

    T1004 a*b problem(HDU 7448) 不会. T1005 小塔的养成游戏之梦(HDU 7449) 不会. T1009 强攻计策(HDU 7453) 容易发现初始速度是多少对答案没有影 ...

  7. Chrome使用回退,出现表单提交失败,ERR_CACHE_MISS问题

    是什么.为什么.怎么办 "ERR_CACHE_MISS" 错误通常发生在你使用浏览器的"返回"按钮时.这种错误与浏览器处理缓存数据的方式有关,特别是在处理表单和 ...

  8. CentOS8安装RabbitMQ3.8.16

    之前安装过旧版的RabbitMQ和Erlang,先卸载. ①:卸载RabbitMQ /sbin/service rabbitmq-server stop yum list | grep rabbitm ...

  9. LDAP和SSO

    什么是LDAP(Lightweight Directory Access Protocol)?很多公司会使用各种开源平台(例如: gitlab. Jenkins. chat 等等),维护这些账号是一件 ...

  10. ToDesk云电脑进军游戏市场,真显卡高性能,新版本可暂停使用时长!

    ToDesk远程控制软件在装机量突破1.5亿后,再度迎来里程碑式的发展.今年,该公司创新推出了云电脑产品,正式涉足云计算领域.这款前沿产品一经发布,便凭借其卓越的性能和使用体验赢得了广大用户的赞誉.近 ...