【发布时间】:2019-02-12 07:35:35
【问题描述】:
我有一个相对较小的表(约 50k 行)。当我选择所有记录时,大约需要 40 秒。该表有 3 个 JSONB 列。当我选择除 JSONB 之外的每一列时,查询大约需要 700 毫秒。
如果我只添加一个 JSONB 字段,查询时间会跳到近 10 秒。
我从不使用 where 子句来引用 JSONB 中的内容,只是选择 *.尽管如此,我还是尝试添加 GIN 索引,因为我看到它们经常被提及为 JSONB 的性能提升器。
我已经完全抽空了。
Postgres 9.6 版
explain (analyze, buffers) select * from message;
Seq Scan on message (cost=0.00..5541.69 rows=52969 width=834) (actual
time=1.736..116.183 rows=52969 loops=1)
Buffers: shared hit=64 read=4948
Planning time: 0.151 ms
Execution time: 133.555 ms
【问题讨论】:
标签: postgresql jsonb