gjhiggins/rdflib — Issue #99: querying a tiny Sleepycat db takes 30 seconds
Author: gjhiggins
Created: 2011-10-19 01:20:24+00:00
State: open

Originally filed by danbrick...@gmail.com on 2009-12-29T18:30:36

I'm running this script to query a pre-populated RDF store. The store only
has two small RDFa files indxed in it...

#!/usr/bin/env python

# queries an RDF quadstore

from rdflib.graph import ConjunctiveGraph

g = ConjunctiveGraph("Sleepycat")
g.open("store", create=True)

q1="""PREFIX foaf:
SELECT ?src1 ?src2 ?x
WHERE {
GRAPH ?src1 { ?gr1 foaf:member [ foaf:openid ?x ] }
GRAPH ?src2 { ?gr2 foaf:member [ foaf:openid ?x ] }
FILTER ( ?src1 != ?src2 )
}"""

for src1, src2, x in g.query(q1):
print src1, src2, x

TellyClub:wordpress danbri$ time ./querytest.py
/Users/danbri/working/rdflib/rdflib-read-only/rdflib/store/MySQL.py:10:
UserWarning: MySQLdb is not installed
warnings.warn("MySQLdb is not installed")
/Users/danbri/working/rdflib/rdflib-read-only/rdflib/store/AbstractSQLStore.py:5:
DeprecationWarning: the sha module is deprecated; use the hashlib module
instead
import sha,sys, weakref
/Users/danbri/working/rdflib/rdflib-read-only/rdflib/sparql/Query.py:1:
DeprecationWarning: the sets module is deprecated
import types, sets, sys
http://danbri.org/words/network http://inkdroid.org/journal/network
http://danbri.org/
http://inkdroid.org/journal/network http://danbri.org/words/network
http://danbri.org/

real	0m33.301s
user	0m32.178s
sys	0m0.376s

Here's the script that loads the db:

#!/usr/bin/env python

from rdflib.graph import ConjunctiveGraph

# Test basic SPARQL aggregation of the RDFa data
# see also http://identi.ca/notice/17728953 http://identi.ca/notice/17729227

g = ConjunctiveGraph("Sleepycat")
g.open("store", create=True)
g.parse("http://inkdroid.org/journal/network", format='rdfa', lax=True)
g.parse("http://danbri.org/words/network", format='rdfa', lax=True)

q1="""PREFIX foaf:
SELECT ?src1 ?src2 ?x
WHERE {
GRAPH ?src1 { ?gr1 foaf:member [ foaf:openid ?x ] }
GRAPH ?src2 { ?gr2 foaf:member [ foaf:openid ?x ] }
FILTER ( ?src1 != ?src2 )
}"""

for src1, src2, x in g.query(q1):
print src1, src2, x