Hi Joe, > Thanks for the reply. Just for reference, using seq is actually > considerably slower. It ran in 39 seconds vs. 4 seconds.
Yeah, tried it here too. It is only 9 seconds vs. 6 seconds, though. > I think it's > because it has to look up every object from disk to get the value of 'id > instead of using the index which is likely in memory. The index appears to > be stored as a simple list of external symbols and the index value. I'm > just guessing through. Not really. While it is correct that the index holds values and symbols, the value is not used here: (iter (tree 'id '+Invoice) '((This) (inc 'N (: id)))) That is, 'iter' iterates all nodes of the index tree, but then loads the object into 'This' and (: id) fetches the value from there (your previous example of 'scan' used only the index). I think I know why (for (This (seq (db: +Invoice)) This (seq This)) (inc 'N (: id))) is a bit slower. In principle, it has less to do, just stepping through the objects with 'seq', which are also nicely in order in the file. But internally it behaves differently. 'seq' is not designed for that purpose, and doesn't use the existing symbols in the Lisp heap. In general, I would not rely to tightly on such isolated tests like the one above, as the results are mostly determined by the system's disk cache behavior, and always try to optimize the production database model. Cheers, - Alex -- UNSUBSCRIBE: mailto:email@example.com?subject=Unsubscribe