.cursor/skills/vector-db-storage/SKILL.md
Storage backends and indexing for vector databases in Elixir. Use when choosing persistence, implementing exact vs approximate k-NN, or integrating pgvector, file, or ETS for vector storage.
npx skillsauth add 8dazo/elix-db vector-db-storageInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| Backend | Use case | Persistence | Scale | |---------|----------|-------------|--------| | ETS | Prototype, small index, low latency | No | < ~100k–500k vectors in memory | | File | Simple persistence, no DB | Yes (binary/term) | Same as ETS, plus disk | | PostgreSQL + pgvector | Production, SQL + vectors | Yes | Large; use IVFFlat/HNSW indexes | | Qdrant (client) | Dedicated vector engine | Yes (external) | Very large |
{id, vector, metadata}; vector as list or binary.terminate/2 or :gen_server.cast(pid, :persist) → write ETS contents to file (e.g. :erlang.term_to_binary(entries) or custom binary format).Use pgvector and Ecto for persistent, indexed storage.
id, embedding (pgvector type), metadata (jsonb/map).embedding for approximate k-NN.<=>, <->) in raw SQL or Ecto fragments; limit k.# Example: nearest neighbors (cosine distance)
# fragment("embedding <=> ?::vector", ^Nx.to_flat_list(query))
| Method | Accuracy | Speed | When | |--------|----------|-------|------| | Exact (scan all) | Exact | O(n) per query | Small n (e.g. < 100k), correctness critical | | IVFFlat (pgvector) | Approximate | Fast | Medium/large, good recall with tuning | | HNSW (pgvector) | Approximate | Very fast | Large, high recall |
For in-memory ETS, start with exact k-NN; move to pgvector (or Qdrant) when n grows or persistence is required.
business
When publishing a new elix-db version or making version changes, run versioned sample use cases, collect memory/time/latency, compare to the previous version report, and update reports. Remember this workflow for releases.
development
Design and implement a vector database in Elixir. Use when building embedding storage, similarity search, k-NN retrieval, or when the user mentions vector DB, embeddings, or semantic search in Elixir.
data-ai
Elixir patterns for vector storage and similarity search. Use when implementing GenServer-based vector store, ETS index, Nx/Scholar distance math, or supervision for a vector DB in Elixir.
development
Debug, verify, and compare elix-db to industry after each plan step. Use after implementing any plan step or changing vector/store/API logic; run tests, IEx checks, and document efficiency vs Qdrant/Milvus/pgvector.