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 ...
随机推荐
- Google Analytics & Ads 学习笔记 2 (gtag 版本)
gtag 是用来取代之前的 ga 的 但其实它底层就是调用 ga 而已. 只是封装了一个上层. 1. start up script <script async src="https: ...
- vue3 3.3.4
https://cn.vuejs.org/guide/introduction.html#what-is-vue 简介 import { createApp } from 'vue' createAp ...
- 面试官的几句话,差点让我挂在HTTPS上
作为软件测试,大家都知道一些常用的网络协议是我们必须要了解和掌握的,比如 HTTP 协议,HTTPS 协议就是两个使用非常广泛的协议,所以也是面试官问的面试的时候问的比较多的两个协议:而且因为这两个协 ...
- Hugging Face 论文平台 Daily Papers 功能全解析
文/ Adeena, 在快速发展的研究领域,保持对最新进展的关注至关重要.为了帮助开发者和研究人员跟踪 AI 领域的前沿动态,Hugging Face 推出了 Daily Papers 页面.自发布以 ...
- python08_05day
#!/usr/bin/python# -*- coding: UTF-8 -*-from _ast import Param #查询数据库'''import MySQLdb conn = MySQLd ...
- 《Vue.js 设计与实现》读书笔记 - 第9章、简单 Diff 算法
第9章.简单 Diff 算法 9.1 减少 DOM 操作的性能开销 在之前的章节,如果新旧子节点的类型都是数组,我们会先卸载所有旧节点,再挂载所有新的子节点.但是如果存在相同类型的节点,我们完全可以复 ...
- 【VMware VCF】使用 SFTP 服务器备份 VCF 核心组件的配置文件。
可以定期对 VMware Cloud Foundation 环境中的相关核心组件(如 SDDC Manager.NSX Manager 以及 vCenter Server 等)创建配置备份,以防止当意 ...
- opengl在编译的过程中,glad使用
我在编译的过程中,遇到:无法找到 -lglad这个错误.最后才发现对于glad的使用不能用-lglad.因为我们通过glad的在线服务可以得到一些文件,其中glad.c文件我们是需要放在我们的项目下面 ...
- 24. echarts 可以画哪些图表
1. 折线图 2. 柱状图 3. 饼图 4. 地图 5. 雷达图 延申问题:画折线图和柱状图哪些配置可以改变样式 1. color 设置每个数据的颜色 2. grid 网格设置图表的大小 3. s ...
- dan
点击查看代码 /* GGrun */ #include<bits/stdc++.h> using namespace std; namespace Octane { //non terra ...