我怎样才能找到RethinkDB表的大小?

时间:2015-10-29 17:54:10

标签: rethinkdb

我无法弄清楚如何获取'test.events'表的数据大小。

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

相关:Get size of Rethinkdb database with Python

2 个答案:

答案 0 :(得分:0)

您可以致电.count()来执行此操作。

答案 1 :(得分:0)

以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显示所有表的总数:

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')
     
相关问题