in reply to Speeding up data lookups
I am thinking that if the identifier list I am working from is also in order, there is a lot of opportunity for speeding up a binary search with some custom code. For instance if I see identifier 8000, I know that no further identifiers will be below 8000, so I can search only from there forward. I could also probably compare the two keys and guess how far forward I should set my midpoint to try to shorten my search.Comparing ID strings or numbers is fast. If you do ten compares with binary search, you have found the 1/1000th part of your data which contain what you look for.
Can you really guess so good that you get to 0.1 % of where you wanted -- in code that is faster than ten compares? Maybe. The people recommending profiling was certainly right. Speed is often not intuitive. (Their advice to find the slow part first and optimize that is certainly good.)
Otherwise, you know the quote?
"Almost all programming can be viewed as an exercise in caching"
Your idea to just pull it into memory (if it fits) sounded good. But it is hard to give specific advice without more specific info.
Any solution to your problem will probably be based on doing some early handling of your data (or something else) that depends upon some details. You need to give more info, I believe.
|
|---|