【问题标题】:How can i find out size of RethinkDB table?如何找出 RethinkDB 表的大小?
【发布时间】:2015-10-29 17:54:10
【问题描述】:

我不知道如何获取“test.events”表的数据大小。

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

相关:Get size of Rethinkdb database with Python

【问题讨论】:

    标签: rethinkdb


    【解决方案1】:

    这将列出 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)}));
    

    【讨论】:

      【解决方案2】:

      您可以致电.count() 进行操作。

      【讨论】:

      • 我相信@AJcodez 表示磁盘上表的大小。
      • mlucy 谢谢,但是是的,dalanmiller 是正确的,希望磁盘上的大小来估算成本
      • 啊,对不起!您可以从统计系统表中获取该信息:rethinkdb.com/docs/system-stats
      【解决方案3】:

      以 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')
           
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-04-12
        • 2014-08-23
        • 2020-04-20
        • 1970-01-01
        • 1970-01-01
        • 2011-04-03
        • 2021-08-10
        相关资源
        最近更新 更多