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 ...
随机推荐
- CSS & JS Effect – 脉冲 Pulse Play Button
效果 参考 Youtube – Create a pulsing animation with CSS 重点 在背后做一个一样大的 div border 然后 animation scale up. ...
- SEO – Schema and JSON-LD
大纲介绍 Schema 是 Google, Microsoft, Yahoo 联合成立的, 目的是统一网页的表示方式, 这样搜素引擎会比较方便显示内容. 它虽然不算那种 w3c 独立的组织. 但其它的 ...
- Figma 学习笔记 – Interactive Components
参考: Input Field Interaction using Interactive Components in Figma Create interactive components with ...
- 文件包含与PHP伪协议
文件包含与伪协议 一.无任何过滤措施的文件包含漏洞:(ctfshow-web78): 1.data://协议: ?file=data://text/plain,<?php system('tac ...
- iOS堆和栈的使用小结
堆和栈都是一种数据项按序排列的数据结构,只能在一端(称为栈顶(top))对数据项进行插入和删除.堆,队列优先,先进先出(FIFO-first in first out):栈,先进后出(FILO-Fir ...
- iOS中搜索框EVNCustomSearchBar使用小结
最近在项目开发中用到了搜索框,之前都是用的系统的searchbar,现有项目中用的是EVNCustomSearchBar,我试了一下还挺方便,下面说一下具体的用法. 第一步:引入添加相关的委托代理EV ...
- 小程序的三大API
小程序的API有宿主环境提供的 : ps:浏览器的定义对象是 window 而微信中的顶级对象是wx :都是不用声明就能调用 : 1. 事件监听 以on开头,监听事件的触发 eg:onWindowRe ...
- Nuxt.js 应用中的 close 事件钩子详解
title: Nuxt.js 应用中的 close 事件钩子详解 date: 2024/10/13 updated: 2024/10/13 author: cmdragon excerpt: clos ...
- java截取##间的话题字符串
转载MARK一下,百度根据关键字不好搜到,省的下次到处找.package iqiyi.com.model;import java.util.regex.Matcher;import java.util ...
- 云原生爱好者周刊:STUNner 助你在 K8s 集群中使用 WebRTC 服务
开源项目推荐 STUNner 目前大多数内网穿透服务都依赖于 STUN 服务或者 TURN 服务,但这些服务大多数都是公用的,即使是私有化部署,也没法迁移到 Kubernetes 的环境中,因为 Ku ...