You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Scylla中system.size_estimates估算值与实际表数据不符问题咨询

Scylla system.size_estimates 估算值与实际行数偏差过大问题

问题回顾

我在Scylla中创建了仅包含chunks表(id text, size bigint)的简单schema,批量导入约3000万行数据后,用dsbulk count得到准确行数:

dsbulk-1.11.0/bin/dsbulk count -k uzzstore -t chunks Operation
directory: /Downloads/logs/COUNT_20230927-100252-630941
total | failed | rows/s | p50ms | p99ms | p999ms
30,593,909 | 0 | 53,207 | 363.11 | 562.04 | 746.59

但执行查询:

select sum(partitions_count) from system.size_estimates where keyspace_name='keyspace' and table_name='chunks';

得到的估算值仅为9069368,远低于实际行数。


这不是预期行为

system.size_estimates的数值是近似值,但正常情况下不会和实际值偏差如此巨大——出现这种情况要么是查询条件错误,要么是统计数据未正常更新。

修复步骤

1. 修正键空间名称拼写

你在dsbulk命令中指定的键空间是uzzstore,但查询语句里写的是keyspace,这是明显的拼写错误。查错键空间自然会得到错误的统计结果。

修正后的查询语句:

select sum(partitions_count) from system.size_estimates where keyspace_name='uzzstore' and table_name='chunks';

2. 手动触发统计数据更新

如果键空间名称无误,可能是自动统计任务因集群负载过高延迟了(默认5分钟更新一次)。可以在每个节点上执行以下命令强制刷新表统计:

nodetool tablestats uzzstore.chunks

该命令会立即收集目标表的分区、行数等统计数据,并同步到system.size_estimates中。

3. 排查节点级统计异常

若手动刷新后偏差仍存在,可查询每个节点的统计数据定位异常节点:

select node, partitions_count from system.size_estimates where keyspace_name='uzzstore' and table_name='chunks';

如果某个节点的partitions_count数值明显偏低,说明该节点的统计数据损坏,可尝试重启该节点后重新执行nodetool tablestats命令。


内容的提问来源于stack exchange,提问作者Ste

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 02:20:13