3

I would like to do a key -> value lookup for data that may not fit into memory (or simply avoid the overhead of having to load it an keep it in memory).

Does Emacs natively support any kind of database that can be used for fast lookups (like a hashtable) without having to first load everything into memory?


As an alternative I could hash the value myself, split it into buckets - then load a JSON file associated with that bucket (for example), but this seems like a weak solution to something that might already exist.

4
  • What did you find on melpa?
    – nega
    Dec 6, 2022 at 15:38
  • 1
    I came across this very old db package on melpa. Also, starting from Emacs 29, SQLite will be included so a k/v store could be built on top of that.
    – g-gundam
    Dec 6, 2022 at 17:41
  • Querying an external database seems the most practical given the goal of eliminating Emacs overhead.
    – lawlist
    Dec 6, 2022 at 17:53
  • 1
    @g-gundam I wasn't aware of sqlite support, this could be made into an answer.
    – ideasman42
    Dec 6, 2022 at 21:53

1 Answer 1

3

Soon... (maybe early 2023)

Starting from version 29, native SQLite support will be included in Emacs.

A key/value store could be built on top of this. There is already a library on MELPA called db which provides an API for key/value stores in Elisp. Its default store uses JSON files, but it was designed so that different backing stores could be used. For example, db-pg provides a PostgreSQL-backed key/value store. Perhaps a db-sqlite could be written. It might be time to breathe life back into db.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.