I am working with an instance of Ontotext GraphDB and often want to clear a named graph with a large number of triples.
Currently, my technique involves issuing a SPARQL command to the graph server, which searches and matches a triple pattern of every triple in the named graph:
DELETE { GRAPH example:exampleGraph { ?s ?p ?o }} WHERE {?s ?p ?o .}
When there are a lot of triples, this approach often takes quite some time to clear the named graph.
I am wondering whether there is a more efficient way to do this. Even a triplestore-specific solution would be acceptable to me.
I should also note that I am using the RDF4J library to communicate with the graph. I understand that certain solutions may work on the Ontotext web interface, but I am only interested in a solution which I can implement programatically.