How to create a database which is based on existed database?

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.

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.

Hi Dominic,

Thanks!

How do I use Copy Database to filter by WHERE query?