我有一个1TB只读数据库,在这里性能是至关重要的。由于查询是由用户动态生成的,因此很难预测它们(整个过程基本上是一个可视化平台,位于大量的医学研究集合之上,用户选择他们想要可视化的内容)。查询通常很复杂,涉及到10+联接。我最近了解了扩展的统计特性,但是我在网上发现很少关于什么时候最好使用它的信息(除了文档中的内容)。
DB是相当好的规范化,但是广泛使用了非规范化的物化视图。在为所有成对列创建扩展统计信息(依赖项和顶n)时是否存在性能损失或其他问题?它将产生大约70个表格的500项统计数字。分析或插入的时间与此无关,只是阅读性能。另外,是否有一个工具或代码片段来帮助我这样做?
我使用Postgresql 12,它尽可能地优化了w.r.t。索引。
发布于 2021-02-09 00:23:02
我认为你最好的办法是设置一个方法来监控相关表和索引计数器的统计数据:
https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ALL-TABLES-VIEW
特别是:
seq_scan bigint
Number of sequential scans initiated on this table
seq_tup_read bigint
Number of live rows fetched by sequential scans
iseq_scan bigint
Number of sequential scans initiated on this table
seq_tup_read bigint
Number of live rows fetched by sequential scans
idx_scan bigint
Number of index scans initiated on this table
idx_tup_fetch bigint
Number of live rows fetched by index scansdx_scan bigint
Number of index scans initiated on this table
idx_tup_fetch bigint
Number of live rows fetched by index scanshttps://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ALL-INDEXES-VIEW
idx_scan bigint
Number of index scans initiated on this index
idx_tup_read bigint
Number of index entries returned by scans on this index
idx_tup_fetch bigint
Number of live table rows fetched by simple index scans using this indexhttps://dba.stackexchange.com/questions/283387
复制相似问题