我如何找出 RethinkDB table 的大小?

How can i find out size of RethinkDB table?

我不知道如何获取 'test.events' table 的数据大小。

r.db('rethinkdb').table('stats').whatGoesHere()
// Output size of 'events' table

相关:Get size of Rethinkdb database with Python

您可以致电 .count() 来完成。

这将列出 space 在 RethinkDB 集群中所有节点的 HDD 上分配:

r.db("rethinkdb")
  .table("stats")
  .filter({db:'test', table:'events'})
  .map(doc => doc('storage_engine')('disk')('space_usage')('data_bytes').default(0))
  .sum()

或者,以 MB 为单位列出 table 大小:

r.db("rethinkdb").table("stats")
  .hasFields('db', 'table')
  .group('db', 'table')
  .map(doc => doc('storage_engine')('disk')('space_usage')('data_bytes').default(0))
  .sum()
  .ungroup()
  .map(doc => ({db: doc('group').nth(0), table: doc('group').nth(1), size: doc('reduction').div(1024).div(1024)}));

要列出 table 大小(以 MB 为单位):

r.db('rethinkdb').table('stats')
  .hasFields('db', 'table')
  .group('db', 'table')
  .map(doc => doc('storage_engine')('disk')('space_usage')('data_bytes').default(0))
  .sum()
  .ungroup()
  .map(doc => ({db: doc('group').nth(0), table: doc('group').nth(1), size: doc('reduction').div(1024).div(1024).round().coerceTo('string').add('MB')}))

要显示 GB 中所有 table 的总数:

r.db('rethinkdb').table('stats')
  .hasFields('db', 'table')
  .group('db', 'table')
  .map(doc => doc('storage_engine')('disk')('space_usage')('data_bytes').default(0))
  .sum()
  .ungroup()
  .map(doc => ({db: doc('group').nth(0), table: doc('group').nth(1), size: doc('reduction').div(1024).div(1024)}))
  .sum('size')
  .div(1024)
  .round()
  .coerceTo('string')
  .add('GB')