title: Nested FOREACH in Neo4J Cypher runs infinite
body: <p>I try to run the following query, where I have 10 chains in database and 10 Countries. and using the array of 20 addresses.
  Then I loop through those to create a store for each combination of country, chain and address, expecting 10*10*20 combinations - 2000 stores.
  But instead, query runs until around 200 000 records are created and then halts with unknown error. </p>
  
  <pre><code>MATCH (Chains:Chain), (Countries:Country)
  WITH Collect(Chains) as ch, 
       Collect(Countries) as cou, 
  ['Ullevål','Blindern','Centrum','Kringså','Lysaker','Skøyen','Fornebu','Stortinget','Nationalteatre','KarlJohan',
  'Gamle','Grunerløkka','Grønland','Majorstuen','Snarøya','Asker','Sandvika','Drammen','Gothenburg','Stockholm'] as addresses
  
  FOREACH(country in cou |
      FOREACH (c in ch |
              FOREACH (a in addresses |
                  CREATE (s:Store {name:c.name+"_"+a, address:a})
                  CREATE (s-[:BELONGS_TO]-&gt;c)
                  CREATE (s-[:IN]-&gt;country)               )))
  </code></pre>