UiPath Community: Communication Mining from Zero to Hero
Tolog optimization
1. The tolog optimizations in Ontopia TMRA, 2010-09-30 Lars Marius Garshol http://ontopia.googlecode.com/svn/trunk/ontopia/src/java/net/ontopia/topicmaps/query/impl/utils/QueryOptimizer.java
2. Query reordering Changes the order in which clauses are executed Can make an enormous difference to execution speed Uses simple cost estimation there are two estimators in Ontopia o:composed_by($OPERA : o:Work, $COMPOSER : o:Composer), o:based_on($OPERA : o:Result, $WORK : o:Source), o:written_by($WORK : o:Work, o:Shakespeare : o:Writer) http://ontopia.wordpress.com/2009/06/18/new-reordering-optimizer/
3. Hierarchy walker Recursive rules do a lot of unnecessary work when evaluating rules using the normal algorithm essentially, already discarded matches come back again Recursive rules usually consist of wrapping, and a recursion step the optimizer finds the recursion step, then runs a transitive closure of it by "pumping" matches through the recursive step Greatly improves the speed of hierarchical queries
4. Rule inlining Given a query like composed-by($C, $O) :- composed-by($C : composer, $O : work). select $OPERA from composed-by(puccini, $OPERA)? the optimizer inlines the rule this gets rid of the overhead involved in calling the rule Could be extended to handling bigger rules, but this is tricky
5. Duplicate remover This optimizer inserts a "fake" predicate which removes duplicate temporary results It analyzes queries to see which ones would benefit from the removal At the moment it only does this with recursive rules The effect there can be enormous
6. String prefix searches Consider the query ph:time-taken($PHOTO, $DATE), $DATE < %time% order by $DATE desc limit 1? It has to find all photos, throw away the ones that are too late in time, sort the remainder, then keep the first The optimizer rewrites this into an index lookup using an ordered index on occurrence values it then pushes all topics with the correct value in increasing order, through the query predicate until it finds enough matches to satisfy the "limit"
7. Faster role access Given a query that contains ... role-player($R1, fixed-point), ... type($R1, roletype), ... the optimizer rewrites this into ... role-player($R1, fixed-point <, roletype>) so that the engine can use a faster method in the API, saving lots of temporary results