Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Calculating Size of a Document via Query

Received: by 10.224.31.20 with SMTP id w20mr8191770qac.2.1349469256648;
        Fri, 05 Oct 2012 13:34:16 -0700 (PDT)
X-BeenThere: mongodb-user@googlegroups.com
Received: by 10.229.176.150 with SMTP id be22ls5657341qcb.4.gmail; Fri, 05 Oct
 2012 13:34:01 -0700 (PDT)
Received: by 10.224.31.20 with SMTP id w20mr8191426qac.2.1349469241860;
        Fri, 05 Oct 2012 13:34:01 -0700 (PDT)
Received: by 10.224.28.72 with SMTP id l8msqac;
        Fri, 5 Oct 2012 13:30:42 -0700 (PDT)
Received: by 10.52.71.38 with SMTP id r6mr1943066vdu.12.1349469041909;
        Fri, 05 Oct 2012 13:30:41 -0700 (PDT)
Date: Fri, 5 Oct 2012 13:30:41 -0700 (PDT)
From: Charlie Mason <charlie.m...@gmail.com>
To: mongodb-user@googlegroups.com
Message-Id: <3c55f28a-39b2-4e16-9400-9982f05ebc02@googlegroups.com>
Subject: Calculating Size of a Document via Query
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_166_14992520.1349469041451"

------=_Part_166_14992520.1349469041451
Content-Type: multipart/alternative; 
	boundary="----=_Part_167_19054394.1349469041451"

------=_Part_167_19054394.1349469041451
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Hi All,

I would like to calculate the size of particular documents in a mongo 
collection. Since the collection will contain many documents created by 
different users I would like to know how large each users documents are. I 
would ideally like to avoid having a collection per user, as ultimately it 
may be shared as a few users may exceed the capacity of one mongod node.

Ideally I would like to calculate the total of all docs that match a 
particular query. I would like this to be as efficient as possible but it 
could be done as a batch job if it might to a few mins to perform. 
I appreciated that the size on disk will be larger because of padding and 
compaction, its the size of the data itself I am after.

If it can't be done at the DB level can I do it when I write to the 
collection via the Java Driver and Morphia? Is there some java code that I 
can use with Morphia to get the size of the documents data?

I would also like to calculate the size of any indexes on fields in a 
document. Is there any way to estimate how much space they will consume. Is 
it just a case of storing the fields value a second time, plus some 
constant overhead presumably? 

It doesn't matter if any of the these calculations are off by a byte or 
two, I just want to be able to calculate rough levels of usage.

Thanks,

Charlie M

------=_Part_167_19054394.1349469041451
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi All,<div><br></div><div>I would like to calculate the size of particular=
 documents in a mongo collection. Since the collection will contain many do=
cuments created by different users I would like to know how large each user=
s documents are. I would ideally like to avoid having a collection per user=
, as&nbsp;ultimately&nbsp;it may be shared as a few users may exceed the ca=
pacity of one mongod node.</div><div><br></div><div>Ideally I would like to=
&nbsp;calculate&nbsp;the total of all docs that match a particular query. I=
 would like this to be as&nbsp;efficient&nbsp;as possible but it could be d=
one as a batch job if it might to a few mins to perform. I&nbsp;appreciated=
&nbsp;that the size on disk will be larger because of padding and compactio=
n, its the size of the data itself I am after.</div><div><br></div><div>If =
it can't be done at the DB level can I do it when I write to the collection=
 via the Java Driver and Morphia? Is there some java code that I can use wi=
th Morphia to get the size of the documents data?</div><div><br></div><div>=
I would also like to calculate the size of any indexes on fields in a docum=
ent. Is there any way to estimate how much space they will consume. Is it j=
ust a case of storing the fields value a&nbsp;second&nbsp;time, plus some c=
onstant overhead presumably?&nbsp;</div><div><br></div><div>It doesn't matt=
er if any of the these calculations are off by a byte or two, I just want t=
o be able to calculate rough levels of usage.</div><div><br></div><div>Than=
ks,</div><div><br></div><div>Charlie M</div>
------=_Part_167_19054394.1349469041451--

------=_Part_166_14992520.1349469041451--