[elephant-devel] Re: Getting count of the number of persistent objectsof a particular class
Alex Mizrahi
killerstorm at newmail.ru
Mon Jan 21 08:58:33 UTC 2008
JN> I did some reading through the mailing list archives and the Elephant
JN> manual, but cannot find a recommended way of counting the number of
JN> persistent objects of a particular class.
JN> I have a method that works (using map-class) but this is way too slow
JN> for my purposes.
JN> I did find some postings from Oct last year about this question but no
JN> definitive answer it seams.
JN> Any advice?
as far as i know, most btree implementation do not have a fast way to count
leafs -- you need to iterate through all of them.
in PostgreSQL (and i think in most relational databases like that) query
"SELECT COUNT(*) FROM tree11" takes time proportional to number of elements
in tree11.
of course it would be much faster to do "SELECT COUNT(*)" then reading all
elements on Lisp side, but it will be flawed anyway.
so, the advice would be to count this parameter yourself. for example, make
btree class-name -> instance count. and update it in initialize-instance
(you can move this functionality to some instance-counter-mixin class), and
whereever you delete them..
More information about the elephant-devel
mailing list