From: Josh Cheek Date: 2009-09-15T03:00:38+09:00 Subject: Re: Pre-allocate large amount of memory? --000e0cd5a1c0a94ce404738d5cfe Content-Type: text/plain; charset=ISO-8859-1 On Mon, Sep 14, 2009 at 12:37 PM, Carsten Gehling wrote: > Robert Klemme wrote: > > > > Maybe it's not such a good idea to read everything in memory. After > > all, retrieving large volumes of data from disk is where RDBMS's > > shine. > > My reason for doing this is simply to avoid multiple sql-queries in a > recursive self-referencing datastructure. Usually this can be avoided by > querying the entire subset of data needed, and manipulate it in memory. > Unfortunately the data in question does not enable me to just query the > subset of data. > > I will definetely have a look at Redis. Seems promising. > > Thanks. > > - Carsten > -- > Posted via http://www.ruby-forum.com/. > > I had a situation like that, where I ended up using one of the nested set implementations (I think it was Awesomer Nested Set) instead of a tree hierarchy. I ended up having to write my own (very ugly) iterating interpreter which analyzed each node in to figure out it's recursive context. It took something like 3 or 4 blocks for the different places you could inject code based on a recursive interpretation, but it did get me down to a single database call, and it did only require a single pass through the data. At one point (debugging, ahem) I was very strongly considering going with the approach you are taking. Good luck with it, and let me know how it turns out, I might opt for that approach instead, next time. --000e0cd5a1c0a94ce404738d5cfe--