title: What is the best way to sync data between 2 Neo4j databases?
body: <p>Currently we have 2 Neo4j databases in our application. We use Spring Data Neo4j (SDN).</p>
  
  <p>First database is our STAGING database, and the other is LIVE database. This is more for the purpose of Versioning and to prevent user messing up LIVE database.</p>
  
  <p>We have about 50.000 nodes and 150.000 relationships. Our STAGING area is meant for small subset of users, and we allow doing CRUD operations only in STAGING. After the user has finalized/verified the data in STAGING, we will push the dataset to LIVE database.
  LIVE is only meant for READ ONLY database, CRUD is only allowed during the sync process. </p>
  
  <p>I am wondering what's the best way to sync data between both databases and the sync should allow incremental updates.</p>
  
  <p>I tried to do sync node by node using Cypher Query + SDN, but I hit a roadblock, it takes way too long.</p>
  
  <pre><code>@Query("START n=node:ItemCode('code:*') "
       + "WHERE has(n.status) AND n.status = 'ACTIVE') "
       + "RETURN n");
  public Iterable&lt;Item&gt; getAllActiveItems();
  </code></pre>
  
  <p>On <strong>SyncService</strong> class which does the sync process from STAGING to LIVE db:</p>
  
  <pre><code>Iterable&lt;Item&gt; items = stagingRepo.getAllActiveItems();
  for(Item item:items) {
  
      Item item = liveRepo.findItem(item.getCode());
      if(item == null) {
          //create item
      } else {
          //update item
      }
  }
  </code></pre>
  
  <p>[UPDATE] Based on answer by <a href="https://stackoverflow.com/users/83490/peter-neubauer">Peter Neubauer</a>, I would like to explore further if there is Database Link concept so that the Cypher query can run on two databases at one go.</p>
  
  <p>Any ideas are welcome.</p>
  
  <p>Thanks,
  Gunawan</p>