[elephant-devel] inherited indices

Alex Mizrahi killerstorm at newmail.ru
Wed Apr 27 19:34:34 UTC 2011


> Currently, I do something along the lines of the following on the results 
> on get-instance[s]-by-XXX functions:
> (remove-if #'(lambda (x) (not (member ',class-name (mapcar #'class-name 
> (sb-mop:class-precedence-list x))))) lst :key #'class-of)
> if I want results on the whole inheritance chain, or
> (remove-if #'(lambda (x) (not (equal ',class-name x)))) lst :key 
> #'class-of) if I want result on the specific class.

I wonder why not just typep?
It should be enough to answer any reasonable class-related query.

> Now I know that efficiency is the issue here, but my (naive , since I 
> havent had performance problems yet) response to that is that since the 
> the search is indexed anyway, does it really matter?
> I mean since the complexity of the search is logarithmic wont the separate 
> hierachical index implementation you propose have diminishing returns?

If you consider only search then yes, in theory there should be no 
significant difference.

But if multiple instances are returned you'll just have more data read and 
sent to the Lisp side, so it will be proportionally slower.

Le'ts consider a situation when you have one base class and M subclasses, 
and each subclass has N instances matching a query on average.
Then with simple inherited index you'll have N*M instances read from 
database, while direct index on subclass would return only N.
Thus M times more data is read.

But it depends on expected value of N. If it is low (e.g N*M<1) then query 
time will be dominated by search but not data read or transfer. So it 
doesn't matter in this case.
But if you queries you run typically return many instances it might be a 
problem. 






More information about the elephant-devel mailing list