首页 文章

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

提问于
浏览
5

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

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

相关:Get size of Rethinkdb database with Python

2 回答

  • 6

    这将列出在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为单位列出表格大小:

    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)}));
    
  • 0

    您可以拨打 .count() 来做到这一点 .

相关问题