Deleting relationships does not reduce the storage in size

35 views
Skip to first unread message

Cherie Pun

unread,
Jun 3, 2016, 7:49:37 PM6/3/16
to Neo4j
Hi, 

I have seen a few questions that were posted from before that it does not free the space up immediately. My application is running analysis over the database repeatedly but each time inserting different number of relationships so I have to remove them before I run the next iteration. The database size seems to be growing continuously even when the relationships are removed. I am wondering if the size of the database will slow my application down because there are so many unused ids.

Thanks!

Michael Hunger

unread,
Jun 3, 2016, 10:01:39 PM6/3/16
to ne...@googlegroups.com
Just restart the db after deleting a lot of relationships will enable record-reuse.
> --
> 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.

Cherie Pun

unread,
Jun 4, 2016, 8:17:24 AM6/4/16
to ne...@googlegroups.com
If I am using java GraphDatabaseService, do I need to create a new embedded database to restart it? Thanks.

Kind regards,
Cherie

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/LiHC2zrN458/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neo4j+un...@googlegroups.com.

Michael Hunger

unread,
Jun 4, 2016, 10:34:54 AM6/4/16
to ne...@googlegroups.com
Shutdown and create new, yes

Von meinem iPhone gesendet

Cherie Pun

unread,
Jun 4, 2016, 11:04:35 AM6/4/16
to ne...@googlegroups.com
Thanks!

Kind regards,
Cherie

Cherie Pun

unread,
Jun 4, 2016, 1:32:28 PM6/4/16
to ne...@googlegroups.com
Hi,

I wrote this snippet of code to restart the database, but it's throwing errors.
private void restartDatabase(){
        if(graphDb != null && graphDb.isAvailable(0)){
            graphDb.shutdown();
        }
        graphDb = new GraphDatabaseFactory()
                .newEmbeddedDatabaseBuilder( new File(PATH_TO_DATABASE ))
                .setConfig(GraphDatabaseSettings.allow_store_upgrade, "true")
                .newGraphDatabase();
        registerShutdownHook( graphDb );
}

private void registerShutdownHook( final GraphDatabaseService graphDb )
    {
        // Registers a shutdown hook for the Neo4j instance so that it
        // shuts down nicely when the VM exits (even if you "Ctrl-C" the
        // running application).
        Runtime.getRuntime().addShutdownHook( new Thread()
        {
            @Override
            public void run()
            {
                graphDb.shutdown();
            }
        } );
    } 

Stacktrace:
Exception in thread "main" org.neo4j.kernel.impl.core.ThreadToStatementContextBridge$BridgeDatabaseShutdownException: This database is shutdown.
at org.neo4j.kernel.impl.core.ThreadToStatementContextBridge.checkIfShutdown(ThreadToStatementContextBridge.java:96)
at org.neo4j.kernel.impl.core.ThreadToStatementContextBridge.hasTransaction(ThreadToStatementContextBridge.java:43)
at org.neo4j.kernel.impl.factory.ClassicCoreSPI.isInOpenTransaction(ClassicCoreSPI.java:199)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacade.beginTransaction(GraphDatabaseFacade.java:335)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacade.beginTx(GraphDatabaseFacade.java:330)
       ....

Any idea why the database is still shutdown instead of restarted? Thanks. 

Kind regards,
Cherie

Cherie Pun

unread,
Jun 4, 2016, 1:38:00 PM6/4/16
to Neo4j
Just found out that I was storing the graphDb in another class and I did not update the reference to it. Sorry for spamming.

Kind regards,
Cherie

Kind regards,
Cherie


Kind regards,
Cherie

> To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.

--
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/LiHC2zrN458/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neo4j+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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/LiHC2zrN458/unsubscribe.
To unsubscribe from this group and all its topics, send an email to neo4j+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages