I ran ap_proto with few different values of NUM_RANGES to understand how it affects selection time and selection efficiency, results are in the notebook (link is at the top).
I tried three values for HTM_MAX_RANGES parameter- 64, 32, and 128 (all previous measurements were done with 64). Here are few observations
Measured as a fraction of DiaObjects that fall into a CCD region compared to number of objects returned from database query. Query envelope should be larger in general but we want it as close as possible to actual region. Here is the measured efficiency for different settings:
The overhead is not too terrible, for our default 64 regions it's about 20%.
Here is the plot which shows this efficiency (colors correspond to different ranges settings):
Time DiaSource select (that we want to optimize) shows some dependency on ranges setting but it's not very prominent (32 is worse than 64, but 128 is not too much better than 64)
And total visit time show some weird behavior for 128:
This is probably the same effect as I saw in previous comment with 256, though 128 is not too bad compared to 256. Interestingly DiaSource select does not show any bad behavior, but DiaObject select has similar picture for 128 though it's not as prominent. This is probably has something to do with concurrency (or lack of it).