Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing relationship index on gremlin is relatively slow
    primarykey
    data
    text
    <p>In Neo4j, I have a relationship index 'index_e_ASSOC_sMETHdGEXP' containing about 180000 edges, all with an attribute 'property'. I want to do a simple query that lists 200 edges from the index, at this point regardless of the property value (later do a query like fetch the same attribute values for the 200 first edge out vertices where the edge property &lt;= 0.01), and fetch a few attribute values from the out node:</p> <pre><code>time = System.currentTimeMillis(); t = new Table(); g.idx('index_e_ASSOC_sMETHdGEXP')[[property: Neo4jTokens.QUERY_HEADER + "*"]][0..200].outV().id.as('nodeId').back(1).alias.as("alias").back(1).chr.as('chr').table(t,["nodeId","alias","chr"]).iterate(); System.currentTimeMillis() - time </code></pre> <p><strong>=713ms</strong></p> <p>Getting the 200 first edges from the index takes <strong>262ms</strong>:</p> <pre><code>time = System.currentTimeMillis(); g.idx('index_e_ASSOC_sMETHdGEXP')[[property: Neo4jTokens.QUERY_HEADER + "*"]][0..200]; System.currentTimeMillis() - time </code></pre> <p>Why is the first query completed so slowly? It shouldn't take this long to get 200 edges from a "predetermined list" and fetch a few attribute values from every output node. I'm a complete newbie when it comes to Cypher and Gremlin, so is there a faster way to do this query, either in Cypher or Gremlin? </p> <p>Edit: ran the query (1) 23 times:</p> <pre><code>==&gt; 1124 ==&gt; 983 ==&gt; 951 ==&gt; 864 ==&gt; 1175 ==&gt; 1189 ==&gt; 889 ==&gt; 917 ==&gt; 822 ==&gt; 872 ==&gt; 795 ==&gt; 736 ==&gt; 840 ==&gt; 1189 ==&gt; 723 ==&gt; 756 ==&gt; 691 ==&gt; 44609 ==&gt; 644 ==&gt; 640 ==&gt; 1110 ==&gt; 1007 ==&gt; 819 </code></pre> <p>Edit2: I have since re-imported the database with the following configuration:</p> <pre><code>dump_configuration=true cache_type=gcr neostore.nodestore.db.mapped_memory=100M neostore.relationshipstore.db.mapped_memory=4G neostore.propertystore.db.mapped_memory=200M neostore.propertystore.db.strings.mapped_memory=1G neostore.propertystore.db.arrays.mapped_memory=1G neostore.propertystore.db.index.keys.mapped_memory=1G neostore.propertystore.db.index.mapped_memory=1G relationship_cache_array_fraction=8 node_cache_array_fraction=8 node_cache_size=3G relationship_cache_size=6G </code></pre> <p>Now the query(1) actually takes longer: <strong>23849 ms</strong>. It's starting to look like a cache issue.</p> <p>Interesting snippets of the db log:</p> <pre><code>2012-07-06 10:51:49,149 DEBUG [neo4j.diagnostics]: System memory information: 2012-07-06 10:51:49,152 DEBUG [neo4j.diagnostics]: Total Physical memory: 26,37 GB 2012-07-06 10:51:49,152 DEBUG [neo4j.diagnostics]: Free Physical memory: 11,99 GB 2012-07-06 10:51:49,153 DEBUG [neo4j.diagnostics]: Committed virtual memory: 16,43 GB 2012-07-06 10:51:49,153 DEBUG [neo4j.diagnostics]: Total swap space: 27,00 GB 2012-07-06 10:51:49,153 DEBUG [neo4j.diagnostics]: Free swap space: 26,96 GB 2012-07-06 10:51:49,154 DEBUG [neo4j.diagnostics]: JVM memory information: 2012-07-06 10:51:49,154 DEBUG [neo4j.diagnostics]: Free memory: 1,84 GB 2012-07-06 10:51:49,154 DEBUG [neo4j.diagnostics]: Total memory: 1,87 GB 2012-07-06 10:51:49,154 DEBUG [neo4j.diagnostics]: Max memory: 13,33 GB 2012-07-06 10:51:49,588 DEBUG [neo4j.diagnostics]: Storage files: 2012-07-06 10:51:49,589 DEBUG [neo4j.diagnostics]: messages.log: 304,72 kB 2012-07-06 10:51:49,589 DEBUG [neo4j.diagnostics]: neostore.propertystore.db.index: 1,02 kB 2012-07-06 10:51:49,589 DEBUG [neo4j.diagnostics]: neostore.propertystore.db: 401,18 MB 2012-07-06 10:51:49,590 DEBUG [neo4j.diagnostics]: neostore.relationshipstore.db.id: 9,00 B 2012-07-06 10:51:49,590 DEBUG [neo4j.diagnostics]: index.db: 1,42 kB 2012-07-06 10:51:49,590 DEBUG [neo4j.diagnostics]: tm_tx_log.1: 0,00 B 2012-07-06 10:51:49,590 DEBUG [neo4j.diagnostics]: neostore.relationshiptypestore.db.names.id: 9,00 B 2012-07-06 10:51:49,591 DEBUG [neo4j.diagnostics]: neostore.propertystore.db.id: 9,00 B 2012-07-06 10:51:49,591 DEBUG [neo4j.diagnostics]: neostore.nodestore.db: 478,88 kB 2012-07-06 10:51:49,591 DEBUG [neo4j.diagnostics]: nioneo_logical.log.active: 4,00 B 2012-07-06 10:51:49,591 DEBUG [neo4j.diagnostics]: neostore.nodestore.db.id: 9,00 B 2012-07-06 10:51:49,591 DEBUG [neo4j.diagnostics]: neostore.propertystore.db.strings.id: 9,00 B 2012-07-06 10:51:49,592 DEBUG [neo4j.diagnostics]: neostore.id: 9,00 B 2012-07-06 10:51:49,592 DEBUG [neo4j.diagnostics]: neostore.propertystore.db.strings: 34,15 MB 2012-07-06 10:51:49,592 DEBUG [neo4j.diagnostics]: neostore.relationshiptypestore.db.id: 9,00 B 2012-07-06 10:53:01,486 INFO [neo4j]: GC Monitor: Application threads blocked for an additional 14826ms [total block time: 14.826s] 2012-07-06 10:54:24,019 INFO [neo4j]: GC Monitor: Application threads blocked for an additional 875ms [total block time: 15.701s] 2012-07-06 10:55:25,441 INFO [neo4j]: GC Monitor: Application threads blocked for an additional 559ms [total block time: 16.26s] 2012-07-06 11:00:16,962 INFO [neo4j]: GC Monitor: Application threads blocked for an additional 775ms [total block time: 17.035s] </code></pre> <p>JVM parameters include </p> <pre><code>-XX:+DisableExplicitGC -Xms2000m, -Xmx15360m </code></pre> <p>It seems that the garbage collector interferes with the execution, why is that? With the JVM params I'm telling to the server instance to use max amount of ~15GB memory which should be plenty.</p> <p>Edit4: Doing query(1) adds the following to the log:</p> <pre><code>2012-07-06 11:40:31,973 INFO [neo4j]: GC Monitor: Application threads blocked for an additional 23745ms [total block time: 23.745s] 2012-07-06 11:40:33,961 INFO [neo4j]: RelationshipCache array size: 17895751 purge count: 0 size is: 0b, 100.0% misses, NaN% collisions (0). 2012-07-06 11:40:33,966 INFO [neo4j]: NodeCache array size: 17895751 purge count: 0 size is: 0b, 100.0% misses, NaN% collisions (0). </code></pre>
    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.
 

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