Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks to all of you who took the time to think about my issue. The suggestions of using Geospatial Indexes seem to be the answer I was looking for. Besides the fact that the indexes are more effective for mongodb the way of querying entire boxes simply rocks!</p> <p>To give some facts: I've just started to rewrite my code and collection data and began with a simple comparison. My data before looked like this:</p> <pre><code> [x1] => 190 [y1] => 18 [x2] => 192 [y2] => 18 [c] => 0 [s] => 0 [b] => Array ( [0] => 0 [1] => 0 ) [m] => 1299365242802 [r] => 32596 [_id] => MongoId Object ( [$id] => 4d72bd7af0528ea82f000003 ) </code></pre> <p>The indexes were:</p> <pre><code> {x1:1,y1:1}, {x2:1,y2:1} </code></pre> <p>Now my data looks like this:</p> <pre><code> [_id] => MongoId Object ( [$id] => 4d825799b15953b90d000000 ) [coords] => Array ( [x] => 190 [y] => 18 ) [x2] => 192 [y2] => 18 [s] => 0 [c] => 0 [m] => 1299365242802 [r] => 32596 </code></pre> <p>index:</p> <pre><code> {coords:'2D'} </code></pre> <p>I compared two scripts. First one queries a box of 400x400 pixels from the old collection and it took:</p> <pre> real 0m0.375s user 0m0.348s sys 0m0.021s </pre> <p>Second script uses the index and queries for the same box but using the geospatial index:</p> <pre> real 0m0.107s user 0m0.096s sys 0m0.012s </pre> <p>That's a huge difference and I only have about 3200objects in my collections (each). My live database/collection already contains about almost 2 million objects now (after 12 days online). I can't wait to benchmark the live data with these scripts. It looks very promising to me! :)</p> <p>Thank you all, Stackoverflow rocks! )</p>
    singulars
    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. 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