6

How to delete Neptune graph or delete all vertex and edges from the graph.

Is there also way from the gremlin. Rather than iterating all the nodes and delete single vertex

5 Answers5

8

Gremlin Code will be g.V().limit(100000).drop().iterate();

Update: g.V().drop().iterate() is sufficient, as drop all queries have now been optimised in Neptune.

The-Big-K
  • 2,672
  • 16
  • 35
  • @Karthik Rajan I'm still getting timeouts on g.V().drop().iterate(). How do we ensure we have the latest neptune engine? It's just saying 1.0.1.0. – Eve Freeman Dec 04 '18 at 15:25
  • You cannot see the version number of your instance presently, but If you do have an update available, you should be to select your cluster and do an upgrade from the console. (You could initiate the upgrade via click/sdk as well using the maintenance actions Api). – The-Big-K Dec 04 '18 at 19:30
  • Are you seeing the timeouts after data size increased? Or after a recent engine upgrade? Have you tried increasing the timeout? – The-Big-K Dec 04 '18 at 19:31
  • 1
    Timeouts still occur in the latest version: "A timeout occurred within the script during evaluation." – smiron Feb 19 '20 at 09:25
  • Will it work if we have condition? `g.V().has("name", "omurbek").drop().iterate();` – omurbek May 05 '20 at 10:07
4

Adding another answer as Amazon Neptune now has an API to delete a whole graph efficiently without needing to use Gremlin. See [1] for details.

[1] https://docs.aws.amazon.com/neptune/latest/userguide/manage-console-fast-reset.html

The reset can be done via a curl command or from the Neptune (Jupyter) notebooks.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
2

g.V().drop().iterate() should be enough. If you are deleting ALL vertices and edges, you don't need to do it in batches or iterate over a fixed number of vertices.

The-Big-K
  • 2,672
  • 16
  • 35
0

g.V().drop().iterate(); Yes batch is not required ,but you have iterate for the Neptune graph db

0

AWS Neptune vertex drop is costly when the number of predicates goes up.

what are predicates ?

https://docs.aws.amazon.com/neptune/latest/userguide/feature-overview-data-model.html

Use Explain api by AWS Neptune to know your number of predicates in your graph db. It also shows the warning if number of predicates is high.

Refer this python script to drop without timeout error and faster way to drop vertices.

https://github.com/awslabs/amazon-neptune-tools/blob/master/drop-graph/drop-graph.py

Raghav
  • 11
  • 1