# Query is taking far too long

**URL:** <https://community.neo4j.com/t/query-is-taking-far-too-long/25928>\
**Category:** Neo4j Graph Platform\
**Tags:** apoc, browser, cypher, relationship\
**Created:** [September 25, 2020, 1:11am UTC](https://community.neo4j.com/t/query-is-taking-far-too-long/25928 "2020-09-25T01:11:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![karthik.shetty](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/karthik.shetty/32/4545_2.png) [@karthik.shetty](https://community.neo4j.com/u/karthik.shetty)\
**Post date:** [September 25, 2020, 1:11am UTC](https://community.neo4j.com/t/query-is-taking-far-too-long/25928/1 "2020-09-25T01:11:07Z")

</div>

Hello, Friends!

I am trying to load some data and create a relationship using a golang-neo4j driver. This query (within golang program) runs forever whereas when I tried using apoc.periodic.iterate it completes within a couple of seconds.

```auto
	return func(tx neo4j.Transaction) (interface{}, error) {
		_, err := tx.Run(`unwind $events as event Merge (p:Product{product_id: event.product_id}) SET p = event
		WITH p MATCH (i:Inventory{inventory_id:''}) WHERE i.product_id <> '' WITH i WHERE i.product_id = p.product_id MERGE (p)-[:PRODUCED_BY]->(i)`,
			map[string]interface{}{"events": data})

```

I have 303 `Product``p` nodes and the `i` of total 406156 nodes (with the above matching condition). I am expecting 401038 `PRODUCED_BY` relationships.

I have indexes created for both `inventory_id` and `product_id`.

I ran the same query using `call apoc.periodic.iterate` with the batchSize of 10000 and it finished within a couple of secs. I am not what I am missing in my golang query. Could someone please help me out here? Thanks!

---

<div class="post-metadata">

**Author:** ![karthik.shetty](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/karthik.shetty/32/4545_2.png) [@karthik.shetty](https://community.neo4j.com/u/karthik.shetty)\
**Post date:** [September 25, 2020, 4:59pm UTC](https://community.neo4j.com/t/query-is-taking-far-too-long/25928/2 "2020-09-25T16:59:46Z")

</div>

I just plugged in the apoc statement to the go program and used session.Run to execute it. It worked like a charm!

---

<div class="post-metadata">

**Author:** ![clem](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/clem/32/4364_2.png) [@clem](https://community.neo4j.com/u/clem)\
**Post date:** [November 17, 2020, 6:02pm UTC](https://community.neo4j.com/t/query-is-taking-far-too-long/25928/3 "2020-11-17T18:02:55Z")

</div>

Do you really want to compare the id with the empty string instead of NULL. I suspect the NULL will go faster.
