相关疑难解决方法(0)

什么是身份列?

我正在查看7/01为 PostgreSQL安排commit-fest,我看到 Pg 可能很快就会获得“身份列”。

我在information_schema.columns 中发现了一些提及但没什么

is_identity         yes_or_no         Applies to a feature not available in PostgreSQL
identity_generation character_data    Applies to a feature not available in PostgreSQL
identity_start      character_data    Applies to a feature not available in PostgreSQL
identity_increment  character_data    Applies to a feature not available in PostgreSQL
identity_maximum    character_data    Applies to a feature not available in PostgreSQL
identity_minimum    character_data    Applies to a feature not available in PostgreSQL
identity_cycle      yes_or_no         Applies to a feature …
Run Code Online (Sandbox Code Playgroud)

postgresql identity postgresql-10

12
推荐指数
2
解决办法
8548
查看次数

一次(保证)更改后索引对“状态”字段的影响

介绍

我有一个 PostgreSQL 表设置作为队列/事件源。

我非常希望保留事件的“顺序”(即使在处理队列项之后)作为 e2e 测试的来源。

我开始遇到查询性能下降的问题(可能是因为表膨胀),并且我不知道如何有效地查询不断变化的键上的表。

初始设置

Postgres:v15

表DDL

CREATE TABLE eventsource.events (
    id serial4 NOT NULL,
    message jsonb NOT NULL,
    status varchar(50) NOT NULL,
    createdOn timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    CONSTRAINT events_pkey PRIMARY KEY (id)
);
CREATE INDEX ON eventsource.events (createdOn)
Run Code Online (Sandbox Code Playgroud)

抓取查询(伪代码)

BEGIN;  -- Start transaction

SELECT message, status
FROM eventsource.events ee
WHERE status = 'PENDING'
ORDER BY ee.createdOn ASC
FOR UPDATE SKIP LOCKED
LIMIT 10;  -- Get the OLDEST 10 events that are pending
-- I …
Run Code Online (Sandbox Code Playgroud)

postgresql index queue event query-performance

3
推荐指数
1
解决办法
502
查看次数