Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions scripts/setup-contacts-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,13 @@ async function main() {
CREATE INDEX IF NOT EXISTS contact_embeddings_profile_idx
ON contact_embeddings USING gin (profile)
`;
try {
await sql`
CREATE INDEX IF NOT EXISTS contact_embeddings_embedding_idx
ON contact_embeddings
USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 100)
`;
console.log("✅ contact_embeddings table + vector index ready\n");
} catch (error) {
console.log(
"⚠️ Vector index skipped (created after first rows):",
error instanceof Error ? error.message.split("\n")[0] : String(error)
);
}
// No approximate vector index (ivfflat/hnsw) on purpose. A personal contact
// store is small, so an exact sequential scan is fast and always correct.
// An ivfflat index with lists=100 + default probes=1 silently returns zero
// rows on a tiny table (it only scans one of 100 clusters). Add HNSW only if
// this ever grows into the tens of thousands of contacts.
await sql`DROP INDEX IF EXISTS contact_embeddings_embedding_idx`;
console.log("✅ contact_embeddings table + indexes ready\n");

// 5. Verify
console.log("5️⃣ Verifying tables...");
Expand Down
Loading