Comments (2)
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.
Perhaps the above explanation should be included in the tutorial to make people aware of this behaviour.
from cozo.
Related Issues (20)
- Inconsistent results of two equivalent programs HOT 4
- Slice index out of bound
- :ensure_not parse error HOT 4
- Can't rename variable to put stored relation HOT 2
- Why must system ops appear alone in a script? HOT 1
- Benchmarks don't build + Rustc version requirements HOT 1
- How to access generated default key HOT 6
- Can a chained query access a preceding query's return relation? HOT 7
- The CLA action seems to run on every comment. HOT 5
- unexpected error of function `trim_start` HOT 4
- Odd index creation parsing HOT 4
- Filters must be a list of filters - bug on python bindings HOT 2
- Unexpected result of `ge` on `-0.0` and `0.0` under magic rewrite HOT 10
- CozoDB unexpected hang HOT 2
- SSE APIs documentation HOT 3
- How to optimize the speed of hnsw vector index creation? HOT 1
- Crash in documentation code HOT 1
- Missing documentation on `$` prefix for parameters HOT 11
- "Corrupted index" error when using the `bind_vector` option in hnsw index search HOT 5
- Cannot drop FTS index, it says it can't find it HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cozo.