如何使用 Python 驱动程序获取 Cassandra table 的大小?

How do I get the size of a Cassandra table using the Python driver?

要使用 Cassendra 存档此 Shell :

nodetool cfstats -- <keyspace>.<tablename>

Python 包裹 - cassendra-driver

文档 - cassendra

nodetool tablestats(以前的 cfstats)中的指标未向驱动程序公开,因此您无法通过 CQL 获取此信息。

这些指标仅通过 JMX 公开。干杯!

实际上,如果您 运行 使用 Cassandra 4.0+,则可以使用虚拟表来实现此目的:

SELECT * FROM system_views.disk_usage
WHERE keyspace_name='Whosebug' AND table_name='baseball_stats';


 keyspace_name | table_name     | mebibytes
---------------+----------------+-----------
 Whosebug | baseball_stats |         1

(1 rows)

我上月初写了一篇关于虚拟表的文章,如果您想了解更多信息:

Leveraging Virtual Tables in Apache Cassandra 4.0