I am currently working on a project for the iPhone that requires access to a lot of hierarchical data stored in a local sqlite database. One of the most common operations is to compute the folding state field. Right now, I am doing this recursively through all the descendants of this element (which can be anywhere from 1 to n levels deep). However, this ends up requiring a lot of sql calls. Each sqlite call on the iPhone takes about 250 ms, and in total it is about 7.7 seconds of processing time. Does anyone have any suggestions to do something like this in less than O (n) time? I think the root of the problem is the huge number of sql calls that I make to reduce.
source share