Mnesia query: less or equal than given key
Erik Reitsma (RY/ETM)
Mon Sep 19 16:06:06 CEST 2005
Using mnesia, is there an efficient way to find the smallest entry in a table with a key equal to or less than a given key?
So suppose that I have keys 10, 23, 33, 34, 56, 100 and I look for 26, I want to get 23 back. If I look for 23, I should get 23.
I could select all entries smaller than or equal to my key, and then take the largest of those, but it seems like I would get an intermediate list that may consist of the entire table (i.e. if my key is larger than the largest key in the table).
I could make my own binary search (the keys are integers anyway), but I wondered if there would be a more elegant way.
More information about the erlang-questions