[elephant-devel] Re: Getting count of the number of persistentobjectsof a particular class
Alex Mizrahi
killerstorm at newmail.ru
Mon Jan 21 17:09:57 UTC 2008
??>> 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.
JN> Right, I'm used to doing "SELECT COUNT" SQL statements, which could be
JN> on any kind of joins and is *very* fast in a relational database.
no, they are not *very* fast. SELECT COUNT(*) takes about 10 ms on a table
with 10000 element in PostgreSQL.
that's about 100 times slower than simple query using index.
you won't notice this if you don't call it frequently, but it can be a
problem for huge databases.
JN> This is a great suggestion.
JN> Just to verify: the writes to the database from the initialize-instance
JN> method; will they occur atomically with the consing of the persistent
JN> class (i.e. I don't need to explicitly wrap things into a transaction)?
there is no implicit transaction around make-instance,
and I would strongly advice wrapping all code that works with DB into
explicit transaction anyway.
More information about the elephant-devel
mailing list