Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-19-2021 06:20 PM
I am ingesting around 2,000 nodes with 0 relationships and a couple of properties. I can do it pretty easily with one of the following queries:
UNWIND $batch as row MERGE (n:Equipment {tagPath: row.tagPath}) SET n += row.props
UNWIND $batch as row CALL apoc.merge.node(row.labels, row.idProps, row.props) YIELD node RETURN COUNT(*)
In the first query, I am hardcoding the Equipment label and so I know that is what is adding to speed, as opposed to the second query I would provide multiple varying labels.
I would prefer the second route where I can have dynamic labels, but a 10x speed difference may make it infeasible.
I am curious if there is some obvious reason that I am missing as to why its so much slower, or if I could make some tweaks to help the second option be faster.
Thanks for any advice,
Keith G.
03-20-2021 01:29 AM
03-20-2021 09:20 AM
I actually had the same index before I ran both queries, and cleared the database out between each one.
CREATE INDEX tagPath FOR (n:Equipment) ON (n.tagPath)
03-20-2021 03:09 PM
Could you use PROFILE
in front of both queries to compare the plan?
03-22-2021 10:06 AM
Weird, I did a bit more testing and it looks like the speed difference is actually coming from something in the Java Driver.
It seems that the query is more efficient using APOC though, but takes about twice as long with the driver. Will have to do more digging!
03-27-2021 05:45 AM
Which version of Neo4j are you using to run this query on?
03-27-2021 08:11 AM
I am using the latest version of the Java driver and neo4j v4.0
03-27-2021 10:29 AM
Hello @Keith.gamble
I would be curious to see what happen if you change:
SET n += row.props
BY
ON CREATE SET n += row.props
Which would fit exactly your apoc statement, still APOC does a little more I guess with the dynamic labelling, might be the cause.
03-27-2021 12:17 PM
There is a list of latest version of java drivers released. Please match the appropriate one and upgrade it. This will probable resolve the issue related to speed.
03-29-2021 08:57 AM
I am using the java driver v 4.2.3 and the database is 4.2.3 as well
03-29-2021 10:36 AM
This didnt actually change anything speed wise.
What is interesting is that the speed isn't faster from a query standpoint, the transaction happens in the same amount of time. Its just slower through the driver to create and close it.
All the sessions of the conference are now available online