Mastering Postgres is single-handedly the most thorough and informative database course I’ve seen. I’ve gone from someone who barely knew the basics of Postgres and how it works to being comfortable with the advanced topics of Postgres.Ryan Hendrickson
Shorten dev cycles with branching and zero-downtime schema migrations.
In this module, we're going to look at pgvector. Pgvector is a Postgres extension of which there are hundreds. We're not going to look at all of them, but we are going to look at pgvector. It's one of the most popular, and it's especially relevant these days because of all the advances in AI.
pgvector can help you store vector embeddings and then query against them. Now, what is a vector embedding? Great question. A vector embedding is basically a long array of floating point numbers. It's kinda wild, but basically the premise is you have an image or a document or a blob of text and you send it off to some AI model. That could be OpenAI, that could be Gemini, that could be Llama, it could be any AI model.
What you get back is a long string of floating point numbers. What those numbers represent is a little bit opaque, but it helps you determine similarity. If you have a vector embedding and then you have a search term, or you have another image, you can turn those into vector embeddings and then compare the embeddings to see if it's similar. This can drive features like recommended next article or if you're e-commerce, a recommended product that you might want to add to your cart based on what is already in your cart. Stuff like that. It can also help with searching. We talked about full text search, but you can have a little bit fuzzier, kinda like sentiment search, that sort of thing with you when you have vector embeddings. We're going to look at pgvector.
We'll start by getting it installed, making sure it's working, creating some vector columns, querying against those columns, doing some nearest neighbor searching, that kind of stuff. Then finally adding some indexes at the end. Pgvector is very broad, it is very robust. We will look at the write down at the middle use case for it. There are dozens of ways to tune it that are a little bit outside of the scope of this module, but you will come away from this module being able to implement pgvector, vector embedding, vector searches, all of that kind of stuff. In Postgres, you do not need a separate vector database. Postgres can do it all.