Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-29-2020 11:52 PM
Hi,
How do I create a new database (sub graph) according to my existed graph?
For example:
MATCH (n: User) -[r: KNOW]-(m: User)
WHERE n.age < 30 and m.age < 30
RETURN n, r, m
The new database would be consisted of n, r, m
Thanks!
The reason why I want to do this is because I have millions of users in my graph and for some reason I probably would never access those users whose age is bigger than 30. I think I could improve the performance if I cut off those useless users.
Solved! Go to Solution.
12-30-2020 01:14 AM
In Neo4j 4.0 you can copy data from one database to another database use neo4j-admin copy command
For example, If you have 2 Nodes in your database -> Person & Movie
bin/neo4j-admin copy --from-database=neo4j --to-database=person_only --delete-nodes-with-labels="Movie"
The above command will create a new database called "person_only" and remove the "Movie" nodes, leaving "Person" and relationships that may interconnect them.
One of the optional solution is to add an extra attribute for the "nodes" of interest like IsActive: True, and query them alone.
Also, did you consider adding index ?
If you can share the Cypher query and Profile output, we can check if we can improve the performance of the query also.
Good luck.
12-30-2020 01:14 AM
In Neo4j 4.0 you can copy data from one database to another database use neo4j-admin copy command
For example, If you have 2 Nodes in your database -> Person & Movie
bin/neo4j-admin copy --from-database=neo4j --to-database=person_only --delete-nodes-with-labels="Movie"
The above command will create a new database called "person_only" and remove the "Movie" nodes, leaving "Person" and relationships that may interconnect them.
One of the optional solution is to add an extra attribute for the "nodes" of interest like IsActive: True, and query them alone.
Also, did you consider adding index ?
If you can share the Cypher query and Profile output, we can check if we can improve the performance of the query also.
Good luck.
12-30-2020 09:16 PM
Hi Dominic,
Thanks!
How do I use Copy Database to filter by WHERE query?
All the sessions of the conference are now available online