Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Statistics of tables in mongodb batch query Library

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In mongodb General use for viewing statistical information of a table: db.t.stats () main information is: "ns": "gqtest.t", "count": 40001, # rows "size": 2188945, # data size unit bytes "storageSize": 1126400, "totalIndexSize": 1851392, # Total index size "indexSizes": {"_ id_": 753664, "age_1_name_1": 1097728} "avgObjSize": 54.72225694357641, "nindexes": 2, # Index number

Write the obtained table name in advance: college.txt file. Mainly through regular matching, you can test and adjust it yourself.

#! / bin/bashuser=adminpasswd=123456database=gqtestaddres=/opt/mongodb3.2.13/bin/mongofile=mongo_data.csvfor I in `cat roomge.txt` do college_name= `$addres-- port 7211-u$user-p$passwd-- authenticationDatabase=admin $database-- eval "db.$i.stats ()" | grep ns | awk 'NR==1 {print $3}' `count=` $addres-port 7211-u$user-p$passwd-authenticationDatabase=admin $database-eval "db.$i.stats ()" | grep count | awk 'NR==1 {print $3}' `size= `addres-port 7211-u$user-p$passwd-- AuthenticationDatabase=admin $database-- eval "db.$i.stats ()" | grep size | awk 'NR==1 {print $3}' `index_num= `$ addres-- port 7211-u$user-p$passwd-- authenticationDatabase=admin $database-- eval "db.$i.stats ()" | grep nindexes | awk 'NR==1 {print $3}' `indexsize= `$addres-port 7211-u$user-p$passwd-authenticationDatabase=admin $database-eval "db.$i.stats ()" | grep totalIndexSize | awk 'NR==1 {print $3}' `echo-e "$college_name $college_name $count $count $size\ n" > $size

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report