With due deference to Brian, I must be candid in expressing my extreme doubts as to whether “an entirely separate server” could possibly be apropos in the present case. (I understand the situation that he is speaking to, and I don’t think that the present situation qualifies.) To my admittedly simple-minded way of thinking, the present problem is a problem that quite-obviously could quite-readily be solved by the use of two in-memory indexes to an in-memory data structure ... a-n-d / o-r by two indexes on an SQL table.
To arrive at an appropriate solution to this problem, we do not need to climb the mountain of exotica. We can satisfy ourselves just as well with the perfectly mundane. The only decision that we must now arrive-at is this: “exactly what are the ‘ruling constraints’ to this problem?” Then, “what is the simplest solution that will satisfy it?”
The only constraint that has so-far presented itself is ... the availability of RAM. However, the validity of this constraint as-presented rests entirely upon the supposition that “the entire data-structure must reside completely in (physical(!) ...) RAM.” If this were the case, then the answer would consist of simple arithmetic. However, I perceive that this is not the only practicable solution. This problem can be solved in a satisfactory manner regardless of memory-size. (We’ve been managing such things for fifty-plus years.)
“In-memory” approaches are unquestionably fast ... i-f “as much memory as one might desire” is, in fact, available ... on production machines as well as developer boxes ... “without delay.” In the real world, alas, this is not the case, and therefore we are obliged to resort more-or-less to files. (And, once we do that, our physical-RAM working-set requirements are dramatically reduced ... thereby re-defining the problem entirely.)
The [only (!) ... ] “in-memory” solution to this problem is actually trivial: “you must define two indexes to the data-structure, in addition to the data-structure itself, and therefore you must possess enough RAM to simultaneously hold all three and to access all three of them without any fear of virtual-memory paging delays. Either you do have such luxury ... o-r ... you don’t. Nothing more need be debated nor discussed.
If “an embarrassment of RAM-riches” cannot be 100% counted-upon, then one is pushed rather-decisively toward the use of a database ... and thus upon an approach that must regard every query to that structure as being “more or less costly.” The “cost-equals-zero proposition” of a pure-RAM solution is eliminated ... as are all of ts theoretical advantages. “Welcome to the Real World ...”
|