Subject: Re: Index problem
Date: Friday 16th April 2010 07:53:20 UTC (over 7 years ago)
Bart Demoen wrote: >> There are a lot of facts in my >> project and time is quite limited. I tried index/1 >> > > Have you tried to profile your program, I mean, are you sure the > performance loss is in the facts ? > Try doubling (roughly) the cost of the facts - perhaps as follows: > > instead of > > fact(1). > fact(2). > ... > fact(n). > > have > > fact(X) :- fact1(X), fail. % perhaps put once(fact1(X)) > fact(X) :- fact1(X). > > fact1(1). > fact1(2). > ... > fact1(n). > > Cheers > > Bart Demoen > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm > _______________________________________________ > SWI-Prolog mailing list > SWI-Prolog@iai.uni-bonn.de > https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog > > > Yes, I use profile to make sure where the problem lies in. When the number facts increases, the running time will increase quickly (maybe linearly) although built-in index is used. I also tried Chris Mungall's index_util module, which provides a flexible hash index with the default hash index. It promoted the performance of queries by 1000 times. So, it is the index that makes the program slow. The drawback of Chris' program is that it must change the original fact clauses to build a hash index.