小编Tha*_*Guy的帖子

我可以在 timescaledb 中使用 hypertables 来获得更好的插入率吗?

我有一个 PostgreSQL 数据库,我运行了大量的负载。我希望这个负载尽可能快。我已经在使用复制命令等。

我一直在阅读关于timescaledb以及它如何提供改进的插入性能。但是,如果我只关心插入性能,我想知道使用 hypertables 而不是常规表是否有任何缺点?

postgresql performance timescaledb postgresql-performance

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

PostgreSQL 中的“块”和“页”是同一个东西吗?

我看过很多讨论 Postgres“块”的博客和视频。这些与其他数据库管理系统实现中的“页面”相同吗?

postgresql terminology

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

为什么添加外键关系后删除操作会变慢?

想象一下关于猫主人的下表。

drop table if exists  owners cascade;
create table owners(
    id bigint primary key generated always as identity ,
    name text not null
)
;

insert into owners(name)
select random()::text from generate_series(1,20000);
--insert 200,000 owners records
Run Code Online (Sandbox Code Playgroud)

当我删除一些所有者记录时,速度非常快:

delete  from owners
where id %10 = 0;
Run Code Online (Sandbox Code Playgroud)

85 毫秒内影响了 20000 行

现在我添加一个名为“cats”的表,它指的是所有者:

drop table if exists cats;
create table cats(
    id serial primary key ,
    name varchar(20000) not null,
    owner_id int not null references owners(id)
);

--insert 1bn cats records
insert into …
Run Code Online (Sandbox Code Playgroud)

postgresql

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

在 postgres 函数依赖统计的上下文中,“完全确定”是什么意思?

我正在遵循此页面中如何在 postgresql 中使用“创建统计信息”的示例。

CREATE TABLE tbl (
                     col1 int,
                     col2 int
);

INSERT INTO tbl SELECT i/10000, i/100000
FROM generate_series (1,10000000) s(i);

CREATE STATISTICS s1 (dependencies) on col1, col2 from tbl;
ANALYZE tbl;

SELECT stxname, stxkeys, stxdependencies
FROM pg_statistic_ext
WHERE stxname = 's1';  
Run Code Online (Sandbox Code Playgroud)

返回:

stxname,stxkeys,stxdependencies
s1,1 2,{"1 => 2": 1.000000}
Run Code Online (Sandbox Code Playgroud)

然而,我对这条线感到困惑

观察这个,我们可以看到 Postgres 意识到 col1 完全决定 col2,因此有一个系数 1 来捕获该信息。

在示例中,col2 中有许多重复的记录。那么 col1 如何“完全确定”col2 呢?这是什么意思?

postgresql

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