【发布时间】:2015-10-29 17:54:10
【问题描述】:
我不知道如何获取“test.events”表的数据大小。
r.db('rethinkdb').table('stats').whatGoesHere()
// Output size of 'events' table
【问题讨论】:
标签: rethinkdb
我不知道如何获取“test.events”表的数据大小。
r.db('rethinkdb').table('stats').whatGoesHere()
// Output size of 'events' table
【问题讨论】:
标签: rethinkdb
这将列出 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)}));
【讨论】:
您可以致电.count() 进行操作。
【讨论】:
以 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')
【讨论】: