"Fossies" - the Fresh Open Source Software Archive

Member "arangodb-3.4.7/Documentation/Examples/geoIndexFilterOptimization.generated" (24 Jun 2019, 4685 Bytes) of package /linux/misc/arangodb-3.4.7.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "geoIndexFilterOptimization.generated": 3.4.6.1_vs_3.4.7.

    1 arangosh&gt; db.geoFilter.ensureIndex({ <span class="hljs-attr">type</span>: <span class="hljs-string">"geo"</span>, <span class="hljs-attr">fields</span>: [ <span class="hljs-string">"latitude"</span>, <span class="hljs-string">"longitude"</span> ] });
    2 { 
    3   <span class="hljs-string">"bestIndexedLevel"</span> : <span class="hljs-number">17</span>, 
    4   <span class="hljs-string">"fields"</span> : [ 
    5     <span class="hljs-string">"latitude"</span>, 
    6     <span class="hljs-string">"longitude"</span> 
    7   ], 
    8   <span class="hljs-string">"geoJson"</span> : <span class="hljs-literal">false</span>, 
    9   <span class="hljs-string">"id"</span> : <span class="hljs-string">"geoFilter/124049"</span>, 
   10   <span class="hljs-string">"isNewlyCreated"</span> : <span class="hljs-literal">true</span>, 
   11   <span class="hljs-string">"maxNumCoverCells"</span> : <span class="hljs-number">8</span>, 
   12   <span class="hljs-string">"sparse"</span> : <span class="hljs-literal">true</span>, 
   13   <span class="hljs-string">"type"</span> : <span class="hljs-string">"geo"</span>, 
   14   <span class="hljs-string">"unique"</span> : <span class="hljs-literal">false</span>, 
   15   <span class="hljs-string">"worstIndexedLevel"</span> : <span class="hljs-number">4</span>, 
   16   <span class="hljs-string">"code"</span> : <span class="hljs-number">201</span> 
   17 }
   18 arangosh&gt; <span class="hljs-keyword">for</span> (i = <span class="hljs-number">-90</span>;  i &lt;= <span class="hljs-number">90</span>;  i += <span class="hljs-number">10</span>) {
   19 ........&gt;     <span class="hljs-keyword">for</span> (j = <span class="hljs-number">-180</span>; j &lt;= <span class="hljs-number">180</span>; j += <span class="hljs-number">10</span>) {
   20 ........&gt;         db.geoFilter.save({ <span class="hljs-attr">name</span> : <span class="hljs-string">"Name/"</span> + i + <span class="hljs-string">"/"</span> + j, <span class="hljs-attr">latitude</span> : i, <span class="hljs-attr">longitude</span> : j });
   21 ........&gt;     }
   22 ........&gt; }
   23 arangosh&gt; <span class="hljs-keyword">var</span> query = <span class="hljs-string">"FOR doc in geoFilter FILTER DISTANCE(doc.latitude, doc.longitude, 0, 0) &lt; 2000 RETURN doc"</span>
   24 arangosh&gt; db._explain(query, {}, {<span class="hljs-attr">colors</span>: <span class="hljs-literal">false</span>});
   25 Query <span class="hljs-built_in">String</span>:
   26  FOR doc <span class="hljs-keyword">in</span> geoFilter FILTER DISTANCE(doc.latitude, doc.longitude, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>) &lt; <span class="hljs-number">2000</span> RETURN doc
   27 
   28 Execution plan:
   29  Id   NodeType        Est.   Comment
   30   <span class="hljs-number">1</span>   SingletonNode      <span class="hljs-number">1</span>   * ROOT
   31   <span class="hljs-number">6</span>   IndexNode        <span class="hljs-number">703</span>     - FOR doc IN geoFilter   <span class="hljs-comment">/* geo index scan */</span>
   32   <span class="hljs-number">5</span>   ReturnNode       <span class="hljs-number">703</span>       - RETURN doc
   33 
   34 Indexes used:
   35  By   Type   Collection   Unique   Sparse   Selectivity   Fields                        Ranges
   36   <span class="hljs-number">6</span>   geo    geoFilter    <span class="hljs-literal">false</span>    <span class="hljs-literal">true</span>             n/a   [ <span class="hljs-string">`latitude`</span>, <span class="hljs-string">`longitude`</span> ]   (GEO_DISTANCE([ <span class="hljs-number">0</span>, <span class="hljs-number">0</span> ], [ doc.<span class="hljs-string">`longitude`</span>, doc.<span class="hljs-string">`latitude`</span> ]) &lt; <span class="hljs-number">2000</span>)
   37 
   38 Optimization rules applied:
   39  Id   RuleName
   40   <span class="hljs-number">1</span>   geo-index-optimizer
   41   <span class="hljs-number">2</span>   remove-unnecessary-calculations<span class="hljs-number">-2</span>
   42 
   43 
   44 arangosh&gt; db._query(query);
   45 [ 
   46   { 
   47     <span class="hljs-string">"_key"</span> : <span class="hljs-string">"125106"</span>, 
   48     <span class="hljs-string">"_id"</span> : <span class="hljs-string">"geoFilter/125106"</span>, 
   49     <span class="hljs-string">"_rev"</span> : <span class="hljs-string">"_Y2g7DsS--J"</span>, 
   50     <span class="hljs-string">"name"</span> : <span class="hljs-string">"Name/0/0"</span>, 
   51     <span class="hljs-string">"latitude"</span> : <span class="hljs-number">0</span>, 
   52     <span class="hljs-string">"longitude"</span> : <span class="hljs-number">0</span> 
   53   } 
   54 ]
   55 [object ArangoQueryCursor, <span class="hljs-attr">count</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">cached</span>: <span class="hljs-literal">false</span>, <span class="hljs-attr">hasMore</span>: <span class="hljs-literal">false</span>]