-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance issue (or infinite loop) #29
Comments
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 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. |
Perhaps the above explanation should be included in the tutorial to make people aware of this behaviour. |
I've tried a variation of this example present in tutorial:
Changing it in this way:
Despite it should be an equivalent query I don't get any result in reasonable time in https://cozodb.github.io/wasm-demo/
I don't think it is expected, am I missing something?
The text was updated successfully, but these errors were encountered: