𝗩𝗲𝗰𝘁𝗼𝗿 𝗧𝗮𝗯𝗹𝗲𝘀 𝟭𝟬𝟭: 𝗨𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱𝗶𝗻𝗴 𝗩𝗲𝗰𝘁𝗼𝗿 𝗮𝗻𝗱 𝗣𝗚𝗩𝗲𝗰𝘁𝗼𝗿

You hear about vectors and pgvector. They sound complex. They are. You do not need to be an expert to use them.

A vector is a list of numbers. Example: [1, 2, 3, 4, 5].

Think of it as a point in space. Two numbers make a 2D point. Three numbers make a 3D point. Hundreds of numbers make a high-dimensional space.

Normal text search looks for exact words. Vector search looks for meaning.

Search for "Postgres database setup tutorial." The database finds "How to configure PostgreSQL." Words differ. Meaning is the same.

AI models turn text, images, or audio into vectors. These are embeddings. The AI puts similar ideas close together. Cat and Dog stay near each other. PostgreSQL and Kubernetes stay in another area.

You find the closest vector with these methods:

Dimensionality is the number of values in the list. More dimensions mean more detail.

Normalization makes all vectors the same length. This makes cosine similarity faster.

PostgreSQL has a tool called pgvector. It lets you store vectors in your tables. You use SQL to find the nearest vectors. The <-> operator finds the distance.

Comparing millions of vectors is slow. Use indexes like IVFFlat or HNSW to speed it up.

Use pgvector for:

Embeddings are points in space. AI is often geometry.

Source: https://dev.to/rmarsigli/vector-tables-101-understanding-vector-and-pgvector-once-and-for-all-3g68