[redland-dev] What is the expected performance of a sparql Query?

Lauri Aalto laalto at gmail.com
Thu Aug 21 13:55:19 BST 2008


On Thu, Aug 21, 2008 at 3:40 PM, Lou Sakey <ljsakey at verizon.net> wrote:
> Here is a copy of the query.
>
> PREFIX lou: <http://ns.lou.com/2007/lou-ns#>
> PREFIX dc: <http://purl.org/dc/elements/1.1/>
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> SELECT * WHERE {
> ?subject lou:Sex ?p0.
> ?subject lou:BirthDate ?p1.
> <http://ns.lou.com/2007/Friends> fam:Person ?subject.
> FILTER (
>  ( (?p0 = 'Male') && (xsd:dateTime(?p1) <=
> xsd:dateTime('2008-01-31T00:00:00')) && (xsd:dateTime(?p1) >=
> xsd:dateTime('2008-01-01T00:00:00')) )
> ) }
>
>
> It is expected to find all males born in January of 2008.

This query essentially pulls all triples with lou:Sex and
lou:BirthDate properties and only then can apply the filter expression
(actually it will do it even later after checking the third graph
pattern). Write the first graph pattern as ?subject lou:Sex "Male" and
drop the (?p0 = 'Male') filter conjunction to make it restrict the
triple set earlier. Generally, filter with graph patterns and not
FILTER expression whenever you can.

Additionally, the hashes storage does not create p2so (predicate to
subject,object) index by default. Add "index-predicates=1" storage
option to enable it. Without it, you can expect horrible performance
for queries that pull out triples by predicate.

Lauri


More information about the redland-dev mailing list