I'm thinking about something along the lines of a service that runs on a web server and has the entire web server all to itself. In particular, all the RAM being the most important. It would load a handful of tables with a large number of records in them. It would load every record in the three tables, except would only load a couple fields in each table, which amounts to less than 10% of the fields. The objects that are instantiated would be stripped down to the point of being classes that conist of a small number of public variables and absolutely nothing else to keep memory consumption to a minimum.
All three tables have a primary key that is an integer and have always had a rule in place on the database server which does not allow deletions. You can search every object based on its primary key - 1 being its index in the array. This should make retrieval quick.
The process would be called by another process running on another computer on a network. It would be passed three arrays of objects with the same signature as the three types of objects being retrieved. The only part already filled in is the primary key fields. It takes each object in the array and sets it's other variables equal to those of the object whose index equals the primary key -1. The array is then returned to the calling process.
The process also has a low priority thread that sleeps for 6 hours, simultaneously re-fetches the lists, swaps the pointers to the first element in the contiguos array afterwards, and releases the memory for the old list and then goes to sleep for another 6 hours. Swapping would be handled by setting a flag for queing incoming calls, waiting for existing calls to finish, swapping, re-allowing call processing, then freeing memory, and then going back to sleep.
I've implemented this all inside the same process and it resulted in EXTREMELY fast data retrieval, except consumed a lot of RAM. However, that was simply a program accessing a cache object which was functioning as this process inside the same program. I don't know if the overhead of calling a seperate process is going to make it run slower than standard DB access yet or not. You would call it once with a couple thousand queries in your list, it would query all three tables once for each entry, and return the results as a big array.
|