Clearing nodes

70 views
Skip to first unread message

Ara

unread,
Feb 27, 2016, 7:43:52 PM2/27/16
to Neo4j
Hi ,
   Recently installed Neo4j community version, I'am not able to clear the node labels, relationship type from database information. Kindly guide me on this issue.Thank you

Michael Hunger

unread,
Feb 27, 2016, 7:46:42 PM2/27/16
to ne...@googlegroups.com
Which version did you use? Did you delete the nodes and relationships in question?

The database keeps them around as they are representations for tokens, but the UI will not show them if they are not in use.

On Sat, Feb 27, 2016 at 6:15 PM, Ara <priy...@gmail.com> wrote:
Hi ,
   Recently installed Neo4j community version, I'am not able to clear the node labels, relationship type from database information. Kindly guide me on this issue.Thank you

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jesse Hemingway

unread,
Mar 5, 2016, 5:08:42 AM3/5/16
to Neo4j
I actually just delete my database if I want to reset everything to a clean slate (shutting down server first). We have an auto-seeding solution that reconstitutes our base data, so that may not be an option for you. Otherwise, MATCH <stuff> DETACH DELETE <stuff> does the job.

But on a related note, I notice that e.g. repeated use of MATCH (n) DETACH DELETE n (with reseeding in between) does not seem to reclaim data storage, and the overall database size keeps growing. Is this expected behavior, or is there some garbage-collection process I need to trigger?

Michael Hunger

unread,
Mar 5, 2016, 8:18:56 AM3/5/16
to ne...@googlegroups.com
Unused recoreds are reclaimed after restart, so if you restart after cleaning out then it will.
But you can also just delete the db-directory.

--

Jesse Hemingway

unread,
Mar 5, 2016, 12:43:30 PM3/5/16
to Neo4j
This is not holding true for my setup, as I've seen my modest 10MB database grow to 250MB over the course of repeatedly testing my seeding logic, and shutting down the server many times as I made configuration changes for new modules, etc. Also, this SO article (outdated? but seems to hold true) indicates that space is not reclaimed. I've come across a tool in the public domain to accomplish neo4j compaction, implying it isn't (or wasn't) automatically supported.

I repeated the restart-server test just now, and it does not alter the size on disk -- the store is 18.2MB (19.4 on disk), twice my 'fresh' data size, and I have reset/reseeded once. Next, I deleted the db, and after reseeding, the size is back down to 9.14, with all the same data as before. My log files were a drop in the bucket either way.

Either way, I'm not going to quibble that if it's more efficient to re-use old records than create new ones, it doesn't make sense to aggressively compact the database. It would just be nice as an option, e.g. to assist in file transfer when moving a database around, etc.

Michael Hunger

unread,
Mar 5, 2016, 4:10:20 PM3/5/16
to ne...@googlegroups.com
Interesting, it works for me:

on empty db, create 100k nodes 100k rels delete everything, check sizes
restart create 100k nodes 100k rels delete everything, check sizes
same size on disk 

wuqour:neo4j-enterprise-2.3.2 mh$ rm -rf test*.db

wuqour:neo4j-enterprise-2.3.2 mh$ bin/neo4j-shell -path test.db

NOTE: Local Neo4j graph database service at 'test.db'

Welcome to the Neo4j Shell! Enter 'help' for a list of commands



neo4j-sh (?)$ foreach(x in range(1,100000) | create (:Person {name:"person "+x, age : x % 100}));

+-------------------+

| No data returned. |

+-------------------+

Nodes created: 100000

Properties set: 200000

Labels added: 100000

5996 ms

neo4j-sh (?)$ unwind range(1,100000) as x match (p) where id(p) = x match (p2) where id(p2) = toInt(rand()*100000) create (p)-[:KNOWS]->(p2);

+-------------------+

| No data returned. |

+-------------------+

Relationships created: 99999

3185 ms

neo4j-sh (?)$ match (n) detach delete n;

+-------------------+

| No data returned. |

+-------------------+

Nodes deleted: 100000

Relationships deleted: 99999

1654 ms

neo4j-sh (?)$ quit

wuqour:neo4j-enterprise-2.3.2 mh$ du -sh test.db/neostore*.db

8,0K test.db/neostore.labeltokenstore.db

1,4M test.db/neostore.nodestore.db

3,9M test.db/neostore.propertystore.db

8,0K test.db/neostore.relationshipgroupstore.db

3,2M test.db/neostore.relationshipstore.db

8,0K test.db/neostore.relationshiptypestore.db

8,0K test.db/neostore.schemastore.db

wuqour:neo4j-enterprise-2.3.2 mh$ bin/neo4j-shell -path test.db

NOTE: Local Neo4j graph database service at 'test.db'

Welcome to the Neo4j Shell! Enter 'help' for a list of commands



neo4j-sh (?)$ foreach(x in range(1,100000) | create (:Person {name:"person "+x, age : x % 100}));

+-------------------+

| No data returned. |

+-------------------+

Nodes created: 100000

Properties set: 200000

Labels added: 100000

5911 ms

neo4j-sh (?)$ unwind range(1,100000) as x match (p) where id(p) = x match (p2) where id(p2) = toInt(rand()*100000) create (p)-[:KNOWS]->(p2);

+-------------------+

| No data returned. |

+-------------------+

Relationships created: 99999

1897 ms

neo4j-sh (?)$ match (n) detach delete n;

+-------------------+

| No data returned. |

+-------------------+

Nodes deleted: 100000

Relationships deleted: 99999

1415 ms

neo4j-sh (?)$ wuqour:neo4j-enterprise-2.3.2 mh$ du -sh test.db/neostore*.db

8,0K test.db/neostore.labeltokenstore.db

1,4M test.db/neostore.nodestore.db

3,9M test.db/neostore.propertystore.db

8,0K test.db/neostore.relationshipgroupstore.db

3,2M test.db/neostore.relationshipstore.db

8,0K test.db/neostore.relationshiptypestore.db

8,0K test.db/neostore.schemastore.db

Jesse Hemingway

unread,
Mar 5, 2016, 6:48:32 PM3/5/16
to ne...@googlegroups.com
Ok, that certainly works. That's a bit boggling -- I have quite a few indexes and constraints, if that could have any effect. I also use the TimeTree module by GraphAware (several at once). I'll play around with a few combinations when I have time to focus on that oddity and hopefully report back with more useful information. Also, when do the disused records get recovered – on shutdown? I'm just running with `neo4j console`, killing it with Ctrl+C each time.

--
You received this message because you are subscribed to a topic in the Google Groups "Neo4j" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/neo4j/nHcFTIRVOI8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neo4j+un...@googlegroups.com.

Michael Hunger

unread,
Mar 6, 2016, 2:25:38 AM3/6/16
to ne...@googlegroups.com
Clean shutdown

Ie "quit" or ctrl-d



Von meinem iPhone gesendet

Jesse Hemingway

unread,
Mar 6, 2016, 3:04:34 PM3/6/16
to Neo4j
Maybe you're referring to `neo4j-shell`, as the suggested commands have no effect for me with `neo4j console` (Neo4j 2.3.2 Community, OSX 10.11.3). The docs here also state:
console 
Start the server as an application, running as a foreground process. Stop the server using CTRL-C.

And with Ctrl-C, shutdown *appears* to be graceful:

$ neo4j console
...

2016-03-06 13:52:33.555-0600 INFO  Remote interface ready and available at http://localhost:7474/

quit

^D

^C2016-03-06 13:52:50.748-0600 INFO  Neo4j Server shutdown initiated by request

...

2016-03-06 13:52:50.852-0600 INFO  Successfully stopped database

2016-03-06 13:52:50.852-0600 INFO  Successfully shutdown database

Michael Hunger

unread,
Mar 6, 2016, 6:19:36 PM3/6/16
to ne...@googlegroups.com
yes I was referring to neo4j-shell


Reply all
Reply to author
Forward
0 new messages