标签: postgresql-14

从 postgresql 中的 pg_stat_statements 删除查询

我需要使用 pg_stat_statements,我已阅读有关 pg_stat_statements_reset() 的信息,它可以丢弃所有统计信息。但是有没有一种函数可以丢弃一个自定义查询的统计信息呢?可以自动删除吗?

postgresql statistics postgresql-14

2
推荐指数
1
解决办法
1139
查看次数

使用 mikro-orm 和 typescript 创建类实例并将其插入 postgresql 数据库时出现问题

我正在尝试按照此React GraphQL TypeScript 教程进行编码

该项目使用 MikroOrm 与 PostgreSQL 数据库进行通信。

目标:创建一个 post 实例并将其插入数据库。

目前我在 19.53 分钟,遇到了以下错误,该错误没有出现在视频中,我不知道为什么。

Post.ts 文件:

@Entity() //correspond to database table.
export class Post {
    @PrimaryKey()
    id!: number;

    @Property({ type: 'date'}) //denote database column, without it its just a class attribute
    createdAt = new Date();

    @Property({ type: 'date', onUpdate: () => new Date() })
    updatedAt = new Date();

    @Property({type: 'text'})
    title!: string;
}
Run Code Online (Sandbox Code Playgroud)

Index.ts 文件:

const main = async () => {
    const orm = await MikroORM.init(microConfig);
    const …
Run Code Online (Sandbox Code Playgroud)

postgresql node.js typescript mikro-orm postgresql-14

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

CREATE INDEX CONCURRENTLY 执行但创建后 CONCURRENTLY 选项丢失?

在 AWS RDS 上的 Postgres 14.3 数据库中,我想在不阻止其他数据库操作的情况下创建索引。所以我想使用该CONCURRENTLY选项,并且我成功执行了以下语句。

CREATE INDEX CONCURRENTLY idx_test
    ON public.ap_identifier USING btree (cluster_id);
Run Code Online (Sandbox Code Playgroud)

但是当检查数据库时:

SELECT * FROM pg_indexes WHERE indexname = 'idx_test';
Run Code Online (Sandbox Code Playgroud)

我只看到:没有选项的索引CONCURRENTLY

我期望索引是使用CONCURRENTLY选项创建的。

是否有任何数据库开关可以打开此功能,或者为什么它似乎忽略CONCURRENTLY

postgresql indexing ddl postgresql-14

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

优化Postgres查询,花时间执行

我有一些需要时间执行的 SQL 查询。无论如何我可以优化,这将需要几毫秒的时间来执行。

select
    item0_.dim_Item_ID as dim_item_id ,
    item0_.description as description ,
    vendorfact1_.vendor_id as vendor_id,
    item0_.origin_country as origin_country ,
    item0_.model as model ,
    vendorfact1_.fid as fid,
    item0_.hovbu as hovbu ,
    item0_.is_adhoc_item as is_adhoc_item,
    item0_.destination_country as destination_country,
    item0_.brand as brand,
    item0_.item_Number as item_Number,
    item0_.retailer as retailer,
    item0_.effective_date as effective_date,
    item0_.creation_date as creation_date,
    vendorfact1_.dim_item_relationship_id as dim_item_relationship_id,
    item0_.item_weight as item_weight,
    item0_.in_box_height as in_box_height,
    item0_.in_box_width as in_box_width,
    item0_.in_box_depth as in_box_depth,
    item0_.status as status,
    item0_.status_desc as col_20_0_,
    item0_.primary_image as primary_image,
    item0_.component_materials as component_materials,
    item0_.product_detail as …
Run Code Online (Sandbox Code Playgroud)

sql postgresql postgresql-14

0
推荐指数
1
解决办法
64
查看次数