I have some code that needs to store 10s of thousands of terms (a global symbol table). After a few experiments, I ended up using library(rbtrees). (I didn’t try @EricGT 's suggestion of N+K trees.) I also wrote some custom code to read and write them quickly, using library(fastrw).