Installing PostgreSQL + pgvector on Debian

farez - Aug 20 '23 - - Dev Community

If you're building any kind of AI app that requires storage of vectors for embeddings, and you need an open source storage solution, it's hard to go wrong with PostgreSQL + the pgvector extension.

You could go with a hosted solution, such as Supabase's vector storage. You can also host it yourself.

It's easy and I show you how to do it for the Debian OS below, which would allow you to add this to a Debian hosted website. This is also the exact setup I'm using for clarifypdf.com, a "Chat with PDF" AI app.

Prerequisities

You'll need root access to your Debian environment.

Steps

SSH into your server, with your username and server's IP address



$ ssh user@ip.add.re.ss


Enter fullscreen mode Exit fullscreen mode

Install pgvector



sudo apt install postgresql-15-pgvector


Enter fullscreen mode Exit fullscreen mode

Login to PostgreSQL



$ psql -U db-username db-name


Enter fullscreen mode Exit fullscreen mode

Enable pgvector



# CREATE EXTENSION pgvector;


Enter fullscreen mode Exit fullscreen mode

Check that it's enabled



# \dx


Enter fullscreen mode Exit fullscreen mode

You should see the extensions list, with pgvector in it.

Screen shot of PostgreSQL extensions list showing that pgvector is enabled.

That's it! You're ready to create embeddings with PostgreSQL!

. . . . . . . . . . . . . . . . . . . .
Terabox Video Player