dusa icon indicating copy to clipboard operation
dusa copied to clipboard

Optimize index creation

Open robsimmons opened this issue 1 year ago • 0 comments

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.

robsimmons avatar Jun 05 '24 20:06 robsimmons