[redland-dev] Querying using SPARQL - misc questions
Anahide Tchertchian
at at nuxeo.com
Tue Feb 7 16:02:53 GMT 2006
Hi,
I've been trying some queries using the SPARQL language, using the W3C
paper to get information, and ran into a few problems.
I'm using the Python binding, and version 1.2.0.1.
1. Querying trying to match literal nodes, I cannot find a way to match
literals with language and datatype set:
- matching Node(literal='test') works using "test" in the query
- matching Node(literal='test', language='en') works using "test"@en
- matching Node(literal='test',
datatype=Uri("<http://cps-project.org/2005/data/>") works using
"test"^^<http://cps-project.org/2005/data/>
- now matching Node(literal='test', language='en,
datatype=Uri("<http://cps-project.org/2005/data/>") does not work using
"test"@en^^<http://cps-project.org/2005/data/> for instance, and I ended
up using a regexp to find nodes with a language AND a datatype set.
Any solution?
2. I have a use case where I "clean" the graph deleting literal nodes
that where found thanks to a query. How come I cannot use nodes from the
result directly? (I have to create them again cloning the result nodes,
otherwise they're not found in the graph).
3. I noticed that the way the query is written has effects on the
answering time. For instance, writing:
SELECT DISTINCT ?node
WHERE {
?node rdf:type <MyRDFType>
?art dcterms:references ?node
}
will be much more efficient than writing:
SELECT DISTINCT ?node
WHERE {
?art dcterms:references ?node
?node rdf:type <MyRDFType>
}
I benched it on a graph containing more than 100,000 statements: the
first query was processed in 1 second, and the second one took more than
15 min (did not wait till the end). This was done using a graph in
memory, so I suppose that's why it may have been so slow.
Are there any tricks to know about writing efficient queries?
I'd be very grateful if someone could give me any indication about one
of these problems. I've got other questions but I'm saving them for later :)
Thanks, regards,
--
Anahide Tchertchian, Nuxeo (Paris, France)
Mail: at at nuxeo.com - Tel: +33 (0)1 40 33 71 60
CPS Platform: http://www.cps-project.org
More information about the redland-dev
mailing list