I don't know exactly the circumstances of what you're trying to
achieve, but if I were you and needed to access by unique id I would
first use +Key in the relations:

(rel id (+Key +String))

Then I would use (db) to access (like you do but without the Pilog):

(db 'id '+Test "1")

I think that's the fastest way, see also (collect) and (aux) for more
utility functions that will let you access the DB without using Pilog.


On Fri, Dec 11, 2009 at 5:25 AM, cle <cle-picol...@qiao.in-berlin.de> wrote=
> Hello,
> today I tried to verify if using a database instead of Pilog facts would
> speed up my processing. While trying this, I stumbled over the
> following. Suppose:
> =A0(pool test)
> =A0(class +Test +Entity)
> =A0(rel id (+Ref +String))
> =A0(rel src (+Ref +String))
> =A0(rel tgt (+Ref +String))
> =A0(new '(+Test) 'id "1" =A0'src A =A0'tgt B)
> =A0(new '(+Test) 'id "11" =A0'src B =A0'tgt "C")
> =A0(new '(+Test) 'id "111" =A0'src C =A0'tgt "D")
> =A0(commit)
> =A0(? (db id +Test 1 @E) (show @E))
> The last Pilog query will successively return three answers where I
> thought to get only one. I understand, why 'db' will deliver three
> results. But the question comes up, how I could formulate the query
> using only exact matches!
> Without this, the 'db' query would return similar matches that I have to
> explicitely guarding against with e.g. 'equal' like this:
> =A0(? (db id +Test "1" @E) (val @Id @E id) (equal @Id "1") (show @E))
> But this would defeat the reason, why I tried to use a DB at all. I
> hoped that accessing an Edge via an index would be faster than asking
> Pilog to match against all its facts until it found a corresponding it
> could unify against.
> So could this be the reason that my DB solution of traversing all ways
> thru a graph is a lot slower than using Pilog facts? Both are trying to
> iterate over the same graph built by 362 edges. Whereas the Pilog facts
> will allow for finding ca. 1000 ways per 1-2 seconds, the database
> solution was canceled after some time, as it did not reach the first
> 1000 solutions before I lost my patience ;-)
> Or is there any way to improve the performance of the DB? For instance
> by only matching exactly in the db query for a certain edge?
> Thanks and Ciao,
> cle.
> --
> UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to