(从我的帖子复制到 postgresql 邮件列表https://www.postgresql.org/message-id/CADBa3wZpuYXwdry2g68NxYmAXOPvx0DLvdAU4kdo2GoPtxKu+Q@mail.gmail.com。不幸的是,我需要至少 10 声誉才能发布 2 个以上链接,因此请参考到原始帖子以获取更多链接)
问题的基本摘要:在 12GB 表中的一列上使用行级安全过滤器会导致位图堆扫描缓慢,而不是作为表所有者执行的查询所使用的快速索引扫描(没有任何行级安全过滤器)。安全)。手动写入过滤条件也可以实现快速索引扫描。比照。https://gist.github.com/charles-cooper/abccf41ce5a1175635414321622fba57查看本文中的所有代码。
表说明如下:
Table "data.sm2dvmoam"
Column | Type | Modifiers | Storage | Stats target | Description
-----------+-----------------------------+-----------+---------+--------------+-------------
item | smallint | not null | plain | |
secid | integer | not null | plain | |
startdate | timestamp without time zone | not null | plain | |
enddate | timestamp without time zone | | plain | |
value_ | real | | plain …Run Code Online (Sandbox Code Playgroud) performance execution-plan row-level-security postgresql-9.5 query-performance