Commit 1b39bf2
Query: shortcircuit clause resolution when result is guaranteed to be empty.
The `-collect` fn, run at the end of a query, correctly shortcircuits with the
following comment: "one empty rel means final set has to be empty"
However, while processing the query clauses, there was no shortcircuit.
Also, since the implementation of `lookup-pattern` is agnostic to
existing rels, this means that attempts to write short-circuiting
clauses at the top of a complex query have very little effect: the
query engine will continue querying the indexes for every tuple that
could possibly match every clause.
This adds a shortcircuit in `resolve-clause` if any existing relation
is empty. The check is cheap, and it should provide a substantial
performance boost in many common cases.1 parent 78cb86d commit 1b39bf2
File tree
2 files changed
+24
-7
lines changed- bench/datascript/bench
- src/datascript
2 files changed
+24
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
113 | 126 | | |
114 | 127 | | |
115 | 128 | | |
| |||
226 | 239 | | |
227 | 240 | | |
228 | 241 | | |
| 242 | + | |
229 | 243 | | |
230 | 244 | | |
231 | 245 | | |
| |||
277 | 291 | | |
278 | 292 | | |
279 | 293 | | |
| 294 | + | |
280 | 295 | | |
281 | 296 | | |
282 | 297 | | |
| |||
298 | 313 | | |
299 | 314 | | |
300 | 315 | | |
301 | | - | |
| 316 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
791 | 791 | | |
792 | 792 | | |
793 | 793 | | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
800 | 802 | | |
801 | 803 | | |
802 | 804 | | |
| |||
0 commit comments