Get Rethinkdb Database Size Using Python

How to get rethinkdb database data size using Python? I want this because I am developing a mutli-user GUI for rethinkdb and want to be able to apply a quota for each user database.

Something like below would be awesome:

r.db('thedatabase').size().run()
50gb
+1
source share
2 answers

RethinkDB does not have a built-in command for such an operation.

The best solution would probably be to deploy multiple instances of RethinkDB on their own (limited) section (using Docker would probably make it easier here).

+3
source

, , , , :

- db rethinkdb RethinkDB. , .

r.db('rethinkdb')
    .table('stats')
    .filter(
        r.row('id').contains('table_server')
    )('storage_engine')('disk')('space_usage')('data_bytes')
    .reduce((left, right) => left.add(right))

, . , stat .

, sharding ( ).

:

r.db('rethinkdb')
    .table('stats')
    .filter(r.and(
        r.row('id').contains('table_server'),
        r.row('server').eq('servername')
    )
    )('storage_engine')('disk')('space_usage')('data_bytes')
    .reduce((left, right) => left.add(right))

, , and

:

r.db('rethinkdb')
    .table('stats')
    .filter(r.and(
        r.row('id').contains('table_server'),
        r.row('db').eq('dbname')
    )
    )('storage_engine')('disk')('space_usage')('data_bytes')
    .reduce((left, right) => left.add(right))

, , db.

r.db('rethinkdb')
    .table('stats')
    .filter(r.and(
        r.row('id').contains('table_server'),
        r.row('db').eq('dbname'),
        r.row('table').eq('tablename')
    )
    )('storage_engine')('disk')('space_usage')('data_bytes')

. , , . . , , .

, ReQL.

, JavaScript arrow (=>). Python .reduce(lambda left, right: left+right).

- , :)

+3

Source: https://habr.com/ru/post/1613701/


All Articles