Choosing the right DB

What this lesson covers

This lesson asks why relational and NoSQL databases are not used for vector search and then picks one for the course's project. Vector databases are described as optimised for two things: compressing one dimensional vectors efficiently and searching an n dimensional space efficiently. A relational index works on sorted data in one dimension, so a name lookup is a binary search, which has no equivalent across n dimensions. Relational databases also provide ACID guarantees and fast updates, which a vector database does not need. Instead, vector databases cluster vectors so nearby ones are found quickly, and a whole cluster can be represented by one point during search, which speeds queries at the cost of some accuracy. That makes them unsuitable for a system that must be perfectly consistent, such as a financial one, but fine for search, recommendations and text generation, which can be inexact. Among the options, the video names pgvector, which runs over Postgres, another newer open source vector database it describes as built for large scale, and managed services such as Vertex AI on GCP and OpenSearch on AWS. The choice rests on three factors: whether the solution meets the requirements (all do), whether the team understands how it works well enough to change or optimise it later, and cost, where setup is similar but managing an open source system costs quite a bit more. Given new, domain specific requirements, the video chooses pgvector.

  • A relational index supports binary search on one sorted dimension, which does not extend to n dimensional vectors
  • ACID guarantees and fast updates are not needed for vector search, which serves inexact uses such as search and recommendations
  • Representing a whole cluster by one point speeds vector queries at the cost of some accuracy
  • The three decision factors are whether requirements are met, whether the team understands the internals, and cost
  • The course chooses pgvector, which runs over Postgres and works at almost all scales