GithubHelp home page GithubHelp logo

Comments (2)

zh217 avatar zh217 commented on August 23, 2024

Unfortunately this is how it is supposed to work now. Let me explain.

In your changed query, you are asking the database to compute the all-pair shortest path, and then extract the answer to a particular shortest path. Normally Cozo would apply a technique called magic set rewrite so that only the needed answer would be calculated. However, in your query the presence of the aggregation operator min prevents that. In this case, applying the rewrite would still yield the correct answer, but in the more general case with recursive aggregations this is a can of worms and mindlessly rewriting could lead to wrong results.

So as explained in the manual, magic set rewrites are only applied to rules without aggregations or recursions for the moment, until we are sure of the exact conditions under which the rewrites are safe. So for now at least the database executes your query as written, computing the result of the shortest rule containing more than ten million rows (to be exact, 3700 * 3700 = 13,690,000 rows) first.

The solution now is, to be careful of the cardinality of the return sets of recursive rules. In your case, if you really need to pre-compute the more than 10M rows (I highly doubt it), you should use the ShortestPathDijkstra algorithm, which is much faster (but still takes some time). Unfortunately you cannot use graph algorithms in WASM due to the lack of support for many critical functions on WASM that make graph algorithms run fast.

Hope this helps.

from cozo.

zh217 avatar zh217 commented on August 23, 2024

Perhaps the above explanation should be included in the tutorial to make people aware of this behaviour.

from cozo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.