# Graph deletion takes a long time

**URL:** <https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524>\
**Category:** Support\
**Created:** [March 15, 2019, 1:18pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524 "2019-03-15T13:18:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![depressiveRobot](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/depressiverobot/32/74_2.png) [@depressiveRobot](https://community.stardog.com/u/depressiveRobot)\
**Post date:** [March 15, 2019, 1:18pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/1 "2019-03-15T13:18:56Z")

</div>

Hello!

We stumbled over the issue that it takes a very long time to add and/or remove large graphs.

## Context

Stardog 6.1.1 with default options plus

- `versioning.enabled=false`
- `preserve.bnode.ids=false`

A test with adding and removing data to/from a graph:

- Create 35 million triples test data using BSBM:

- Add data:

- Remove data:

The same behavior applies for the update query `DROP SILENT GRAPH <http://example.org/>`.

## Issue

Our issue is that we need a way to trigger a graph removal which doesn't block the call until the graph is successfully removed. **Is there any way to accomplish this?** Like a way to trigger a graph removal in the background.

---

<div class="post-metadata">

**Author:** ![matthias](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@matthias](https://community.stardog.com/u/matthias)\
**Post date:** [March 15, 2019, 1:35pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/2 "2019-03-15T13:35:18Z")

</div>

Maybe I am proposing something that is almost too simple:

> $ stardog data remove -g [http://example.org/](http://example.org/) stardog &

Note the “&” added to the end of your command which would send the command/transaction into the background and allow your script to continue otherwise.

---

<div class="post-metadata">

**Author:** ![depressiveRobot](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/depressiverobot/32/74_2.png) [@depressiveRobot](https://community.stardog.com/u/depressiveRobot)\
**Post date:** [March 15, 2019, 1:53pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/3 "2019-03-15T13:53:08Z")

</div>

Okay, sorry. I forgot to mention that we connect to Stardog over the Java API and we have our own browser-based interface. How can we achieve that the user doesn't have to wait until the remove operation is done. Maybe, can we use the transaction API for that? Like, triggering the removal and later get some feedback if the removal was successful. Do you now understand our problem?

---

<div class="post-metadata">

**Author:** ![matthias](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@matthias](https://community.stardog.com/u/matthias)\
**Post date:** [March 15, 2019, 2:03pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/4 "2019-03-15T14:03:20Z")

</div>

The experts may have better ideas. My first reaction would be: Java threads are your friend.

(And don't share connection objects across threads, especially in this case.)

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [March 16, 2019, 3:51pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/5 "2019-03-16T15:51:34Z")

</div>

I’m not sure exactly what you’re looking to do but you can always use named graph security to restrict access to the named graph and then delete it lazily.

---

<div class="post-metadata">

**Author:** ![depressiveRobot](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/depressiverobot/32/74_2.png) [@depressiveRobot](https://community.stardog.com/u/depressiveRobot)\
**Post date:** [March 18, 2019, 10:18am UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/6 "2019-03-18T10:18:06Z")

</div>

It is not about access to the graph to be deleted, but how can we delete a large graph without letting the user wait until success. Yeah, we can implement threading in our application, however, I was wondering if Stardog itself already provides something for this?

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [March 18, 2019, 1:09pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/7 "2019-03-18T13:09:58Z")

</div>

I don't believe that Stardog itself provides what you're looking for.

---

<div class="post-metadata">

**Author:** ![mgns](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@mgns](https://community.stardog.com/u/mgns)\
**Post date:** [March 18, 2019, 1:19pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/8 "2019-03-18T13:19:09Z")

</div>

Okay, if that long-running graph deletion process is encapsulated in a separate thread on client side, so that the user does not have to wait for its completion. What about inserting data into this very same graph afterwards. Could this be done instantly or does the user have to wait until the deletion has completed anyways?  
Our workflows rely on dropping a graph entirely and re-running the import again. So it would be great to save the time we would need for deleting the graphs (especially if it is several minutes).

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [March 18, 2019, 2:05pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/9 "2019-03-18T14:05:51Z")

</div>

You might be able to do what you're looking for by writing a custom HTTP handler extension.

> **[stardog-examples/examples/http\_handler at develop ·...](https://github.com/stardog-union/stardog-examples/tree/develop/examples/http_handler)**
>
> develop/examples/http\_handler

---

<div class="post-metadata">

**Author:** ![matthias](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@matthias](https://community.stardog.com/u/matthias)\
**Post date:** [March 18, 2019, 2:23pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/10 "2019-03-18T14:23:03Z")

</div>

One would assume, if these are two independent transactions, that the Stardog server will know how to serialize and process them in the right order. It should work now and faster in the future. Look here: [Home | Stardog Documentation Latest](https://www.stardog.com/docs/#_snapshot_isolation)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [April 1, 2019, 2:23pm UTC](https://community.stardog.com/t/graph-deletion-takes-a-long-time/1524/11 "2019-04-01T14:23:14Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
