Search code examples
sparqlrdfdatalogrdfox

Datalog Rule taking forever to compute


I'm using RDFox v3 and when I import the following rule it takes a long time to run. My datastore has CRM information and I'm trying to classify their origins using rules.

[ ?customer, :referral, "true"] :-  [ ?customer, :has, ?referralLink] .

I don't see what I'm doing wrong.

Thank you!


Solution

  • This suggests you have a lot of :has relationships in your data. If this is the case the variables you have listed as ?customer and ?referralLink are matching on everything that is related by :has. This is happening regardless of whether they are a customer or not and that is what I suggest may be taking the time.

    If ?customer and ?referralLink have types you might want to specify this in your rule. For example supposing they are of type :CustomerType and :ReferralLinkType then your rule will become:

    [ ?customer, :referral, "true"] :- 
       [ ?customer, :has, ?referralLink] ,
       [ ?customer, a, :CustomerType] ,
       [ ?referralLink, a, :ReferralLinkType] .
    

    Hopefully that helps.