I have a database with five possible index columns, all of which are useful in different ways. Let them be called System, Source, Heat, Time, and Row. Using System and Row together, you will create a unique key and, if sorted by System-Row, the database will also be sorted for any combination of the five index variables (in the order in which they are listed above).
My problem is that I use all combinations of these columns: sometimes I want to JOIN each System row to the next System (Row + 1), sometimes I want GROUP or WHERE through System-Source-Heat, sometimes I want to see all System records -Source WHERE. Time is in a specific window, etc.
Basically, I want the index structure to function similarly to every possible permutation of these five indexes (in the correct order, of course), without actually doing every permutation (although I am ready to do this if necessary). I am engaged in statistics / analytics, and not traditional work with databases, so the size of the index and the speed of its creation / updating are not a problem; I only care about speeding up my impromptu requests, as I tend to invent them, launch them, wait 5-10 minutes, and then never use them again. Thus, my main concern is to “wait 5-10 minutes” for something more, for example, “wait 1-2 minutes”.
My sorted data looks something like this:
Sys So H Ti R 1 1 0 .1 1 1 1 1 .2 2 1 1 1 .3 3 1 1 2 .3 4 1 2 0 .5 5 1 2 0 .6 6 1 2 1 .8 7 1 2 2 .8 8
EDIT: It can make it a little easier that the system should almost always be turned on as the first column to make any of the 4 columns in sorted order.
source share