2
votes

Using markLogic version 8.0-6.3

I am inserting and deleting triples in MarkLogic using

WITH <>
DELETE {}
INSERT {}
WHERE {}

clause.

In the insert clause there are almost 3000 triple patterns, on the running the query I am getting below error.

**2019-01-17 12:53:08.230 Notice: TaskServer: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token memory exhausted

When I limited the triple patterns to 2043 in the INSERT clause then there is no error.

Seems like there is some limit on the number of triples can be inserted at one time, if that's the case is there is any way to increase the limit.

This is my sample code.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xs: <http://www.w3.org/2001/XMLSchema>
PREFIX skos-mla: <http://www.mlacustom.com#>
PREFIX term: <http://www.mla.com/term/>
PREFIX name: <http://www.mla.com/name/>
PREFIX work: <http://www.mla.com/work/>
PREFIX text: <http://www.mla.com/text/>
PREFIX rindicator: <http://www.mla.com/roleindicator/>
PREFIX facet: <http://www.mla.com/facet/>
PREFIX subfacet: <http://www.mla.com/subfacet/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
WITH <thesaurus-term>
DELETE {
    ?termiri skos-mla:hasSRsortCode ?predicate.
    ?termiri skos-mla:hasSSsortCode ?predicate.
    ?termiri skos-mla:hasVSsortCode ?predicate.
    ?termiri skos-mla:hasXSsortCode ?predicate.
    ?termiri skos-mla:hasZSsortCode ?predicate.   
} INSERT {
    term:1 skos-mla:hasZSsortCode 'aaa'.
    term:2582 skos-mla:hasZSsortCode 'aab'.
    term:162 skos-mla:hasZSsortCode 'aac'.
    term:136 skos-mla:hasZSsortCode 'aad'.
    term:709 skos-mla:hasZSsortCode 'aae'.
} WHERE {
    optional {?termiri skos-mla:hasSRsortCode ?predicate.}
    optional {?termiri skos-mla:hasSSsortCode ?predicate.}
    optional {?termiri skos-mla:hasVSsortCode ?predicate.}
    optional {?termiri skos-mla:hasXSsortCode ?predicate.}
    optional {?termiri skos-mla:hasZSsortCode ?predicate.}
}
1
You should run 2 queries, one DELETE ... WHERE ...and one INSERT DATA - this makes much more sense.UninformedUser
By the way, what's the idea of the WHERE part? an OPTIONAL is a left-join and in your case on nothing on the left side, i.e. the empty table, I'm not sure whether this will workUninformedUser

1 Answers

6
votes

Both the delete and the insert sections of that update statement are executed for each result row from the where section. Since the insert doesn't rely on any variables from the where section, that's probably not what you want. You should try to execute the insert part as a simple "insert data" statement instead.