我想检查 btree 索引的内容。
然而,每个 pageinspect 的 btree 函数都表示“channel_status_pkey_index”不是 btree 索引
表格如下所示:
CREATE TABLE public.channel_status (
partition_id int2 NOT NULL,
game public."game" NOT NULL,
channel_id int4 NOT NULL,
platform_partition int4 NOT NULL,
enabled bool NOT NULL,
modified timestamptz NOT NULL,
CONSTRAINT channel_status_pkey PRIMARY KEY (partition_id, game, channel_id, platform_partition)
)
PARTITION BY LIST (partition_id);
它会自动在主键上创建 btree 索引。我还创建了显式索引
CREATE UNIQUE INDEX channel_status_pkey_index ON ONLY public.channel_status USING btree (partition_id, game, channel_id, platform_partition)
但是,如果我运行任何 btree 函数,无论我是否将channel_status_pkey
或channel_status_pkey_index
与“public”一起使用,它都会失败。前缀或不带:
# SELECT * FROM bt_metap('public.channel_status_pkey_index');
ERROR: "channel_status_pkey_index" is not a btree index
你知道为什么 postgres 声明 btree 索引不是 btree 索引吗?
因为它是分区索引,而不是常规索引。
与分区表类似,分区索引不保存任何数据,因此将它们与 pageinspect 的函数一起使用是没有意义的。实际的索引数据保存在索引的分区中,这些分区是表分区上的索引。您应该对这些索引分区使用 pageinspect 函数。