Currently i am asserting items with a first argument an atom that is an identifer, such as so:
when accessing item by identifier, its indexed on the first argument – getting the full speed of indexing.
What if i were to assert item as follows:
i.e. make the first argument a composite, or a pair.
The idea here is to pass along in my system the type of an item along with its identifier.
Would this negatively impact item lookup – i.e. indexing a composite or pair instead of an atom.
I am assuming, for now, that all lookups will be of the form item(X), with X the passed around composite or pair as well.
Alternatively, i could create a new concatenated atom instead - but, would then need to split the concatenated atom if i want to access the type information, a very frequent operation – which, i think would be an expensive step to do – best if i could access the type via binding.
Btw, another approach is to create an additional predicate for type information such as item_ type(item_1) and item_type_2(item_1) – e.g. if more than one type apply to an item.
This however adds predicate lookups for each type query – i am hoping to get to the type information with at most one lookup.
I did a little benchmark, and it seems that using a compound term or pair does effect a slow down – perhaps, in the 12% to 16% range, overall (via profile/1), and it seems that a pair (X-T) is a bit speedier than a compound term, as first argument.
I would need to see what speed up i get with reducing fact lookup, when using such a solution and whether its worth … would however need major refactoring of my code.
Does this make sense, more broadly .
any thoughts are much appreciated,