On Thu, 2005-03-24 at 10:57 -0500, Thomas Briggs wrote: > After posting my question, I found the discussion of how aggregate > operations are performed in the VDBE Tutorial; that implies that memory > usage will correspond with the number of unique keys encountered by the > query, but I appreciate having it stated explicitly. > > How difficult would it be, in concept, to change the storage of the > hash buckets from in-memory to on-disk? The VDBE Tutorial makes it > sound like it would be a matter of changing the AggFocus, AggNext, and > maybe a few other operations to store/retrieve buckets from disk before > operating on them in memory. How dramatically am I oversimplifying > this? :) >
You have the right idea. But the job is really much easier. All of the Agg* opcodes already use the standard btree mechanism for storing and retrieving their buckets. But they use a ":memory:" btree by default. To make it use disk, all you have to do is get it to store the btree in a temporary file on disk. One easy way to make this happen is to recompile with -DSQLITE_OMIT_MEMORYDB. See source file vdbeaux.c near line 800 for additional information. If you want to hack together a customized version of SQLite that behaves differently, that would be a good place to start. -- D. Richard Hipp <[EMAIL PROTECTED]>