<docbook><section><title>VirtTipsAndTricksGuideDeleteLargeGraphs</title><title> How can I delete graphs containing large numbers of triples from the Virtuoso Quad Store?</title> How can I delete graphs containing large numbers of triples from the Virtuoso Quad Store?
<para>By default, triple deletion is performed as part of a transaction, which is stored in memory until the operation is completed and committed to the database.
 During typical server operation, deleting one or more graphs containing a large number of triples (generally millions or more) can consume available memory to the point where the operation <emphasis>cannot</emphasis> be completed, and thus the graph(s) cannot be deleted.</para>
<para>Such large graphs can be cleared by changing the transaction log mode to autocommit on each operation, deleting the graph(s) or triples.
 This is easily done using the Virtuoso <ulink url="http://docs.openlinksw.com/virtuoso/fn_log_enable.html">log_enable</ulink> function, with the settings log_enable(3,1).</para>
<para>This function may be called on its own, prior to the delete operation, via iSQL (either command-line or the Conductor variant), as shown: </para>
<programlisting>log_enable(3,1);
SPARQL CLEAR GRAPH  &lt;graph-name&gt;; 
</programlisting><para> log_enable() may also be called as a pragma specified in a SPARUL query: </para>
<programlisting>SPARQL DEFINE sql:log-enable 3 
CLEAR GRAPH  &lt;graph-name&gt;; 
</programlisting><para> Triples can also be deleted directly from the RDF_QUAD table via SQL, but note that this method will not remove any free-text index data that might be associated with the graph, which CLEAR GRAPH ... would do automatically.
 The SQL operation would look something like this: </para>
<programlisting>log_enable(3,1);
DELETE FROM rdf_quad WHERE g = iri_to_id (&#39;http://mygraph.org&#39;);
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Related</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="VirtTipsAndTricksGuide">Virtuoso Tips and Tricks Guide</ulink> </listitem>
<listitem><ulink url="http://docs.openlinksw.com/virtuoso/sparqlextensions.html#rdfsparul">Virtuoso SPARUL Update Language For RDF Graphs</ulink> </listitem>
</itemizedlist></section></docbook>