dusa
dusa copied to clipboard
Optimize index creation
Right now if we have two rules:
a X Z Z :- c X Z.
a X Y Z :- b X, b Y, c X Z.
a X Z Z :- b X, b Z, c X Z.
a X Z Z :- b Z, c X Z.
Then we'll create four indices, one for each of the four rules:
- Enumerate all the items in
c - Given the first argument in
c, enumerate the defined second arguments - Given the first two arguments of
c, is the relation defined? - Given the second argument in
c, enumerate the defined first arguments
this is unnecessary and wasteful! We do need two indices, one to give us the second argument if we have the first, and one to give us the first argument if we have the second, but either of those indices can be used to calculate the first and last index.