asg017 / sqlite-vss

A SQLite extension for efficient vector search, based on Faiss!
MIT License
1.59k stars 58 forks source link

JSON / buffer performance #111

Open tap2k opened 6 months ago

tap2k commented 6 months ago

Are there any performance differences between using buffers and JSON strings to store embeddings?

FYI on node I am only able to get node-sqlite3 (and not better-sqlite) to work with JSON storage.

asg017 commented 6 months ago

Whether you insert vectors as buffers or JSON, it'll be stored in the same way, so there's no storage-related benefit either way. There may be some small CPU perf improvement if you use buffers instead (since it doesn't need to serialize/deserialize JSON), but you probably won't notice much of a difference.

Insert data with JSON in better-sqlite should work the same - do you mind sharing some sample code? Be sure to call JSON.stringify() before passing in vectors