# Load CSV taking excessive amount of time

**URL:** <https://community.neo4j.com/t/load-csv-taking-excessive-amount-of-time/61055>\
**Category:** Neo4j Graph Platform\
**Created:** [February 22, 2023, 6:03pm UTC](https://community.neo4j.com/t/load-csv-taking-excessive-amount-of-time/61055 "2023-02-22T18:03:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![henry007](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/henry007/32/27619_2.png) [@henry007](https://community.neo4j.com/u/henry007)\
**Post date:** [February 22, 2023, 6:03pm UTC](https://community.neo4j.com/t/load-csv-taking-excessive-amount-of-time/61055/1 "2023-02-22T18:03:14Z")

</div>

Hello, my LOAD CSV query is taking a very long time, despite having indexes on my columns and a unique constraint on PersonId.

It sometimes takes over 5 minutes for a CSV file with 27k records that is just under 3MB.

Here is my query:

```auto
LOAD CSV WITH HEADERS FROM ('myurl.csv') AS row 
MERGE (n:Person {name: row.PersonId }) 
SET n += {EmailAddress: row.EmailAddress, PhoneNumber: row.PhoneNumber}
RETURN true

```

I have also tried ON CREATE SET with no performance improvement.

Can anyone help me figure out what is causing it to take so long?

Thank you!

---

<div class="post-metadata">

**Author:** ![lyonwj](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/lyonwj/32/27358_2.png) [@lyonwj](https://community.neo4j.com/u/lyonwj)\
**Post date:** [February 22, 2023, 6:31pm UTC](https://community.neo4j.com/t/load-csv-taking-excessive-amount-of-time/61055/2 "2023-02-22T18:31:28Z")

</div>

Hi @henry007 -

Be sure that your uniqueness constraint has been created for the correct node property. Given the Cypher statement you shared the uniqueness constraint should be on `:Person(name)` (not `PersonId`).

You can confirm the index / constraint is being used by adding `PROFILE` to the beginning of your Cypher query and examining the query plan for usage of the index.

`ON CREATE SET` will improve performance by not setting property values for nodes that already exist (when the `MERGE` statement matches instead of creating).

---

<div class="post-metadata">

**Author:** ![henry007](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/henry007/32/27619_2.png) [@henry007](https://community.neo4j.com/u/henry007)\
**Post date:** [February 22, 2023, 6:37pm UTC](https://community.neo4j.com/t/load-csv-taking-excessive-amount-of-time/61055/3 "2023-02-22T18:37:06Z")

</div>

Hello, creating the constraint on :Person(name) fixed my issue! Thank you so much!
