Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks like the example query you give for an id of 6 matches 47402 documents:</p> <pre><code>&gt; db.results.find({id:6}).explain() "n" : 47402, </code></pre> <p>and the average document size is about 14654 bytes:</p> <pre><code>&gt; db.results.stats() "avgObjSize" : 14654.313273911172, </code></pre> <p>Does this match your view of the situation?</p> <p>This means that the results from this query will be about 662 MB in size. If the 662 MB of documents returned by the query are not in memory and must be fetched from disk then a lot of disk activity will result and the query will take a long time.</p> <p>There are a few ways you could improve performance, depending on your application requirements:</p> <ul> <li><p>use a more specific query that matches fewer documents, for example use _id to fetch a single document or specify a datetime as well as an id in your query.</p></li> <li><p>refactor your document schema to make the documents you wish to query smaller.</p></li> <li><p>use a projection in the query to select only a subset of the 14KB document to return and build an index that contains the fields in that query projection, so that the query can be satisfied entirely from the index. Note however that this will only work if you select a small enough subset of the document so that your index does not grow to be large, putting you back in the same situation of having to page the index in from disk. The db.results.stats() output tells you how big your indexes are.</p></li> <li><p>equip your server with enough memory so that the collection will remain entirely in memory. The collection size is about 26 GB so you would need at least that much memory for this approach:</p> <blockquote> <p>db.results.stats() "size" : 26662218768,</p> </blockquote></li> </ul> <p>Hope this helps,</p> <p>Bruce</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload