Loading topic
CREATE TABLE, INSERT, SELECT, WHERE, ORDER BY, LIMIT) and have used PostgreSQL through psql or another client. You should have a rough idea of what a text or image embedding is. The Python snippets use NumPy and are optional. No pgvector ins5 min readvector type into a database. It assumes you can connect with psql, know basic SQL, and have a rough idea of what an embedding is. The later chapters rely on a working extension, so the chapter also shows how to check that it works.4 min readCREATE TABLE, INSERT, SELECT), use psql, and know that an embedding is an array of numbers produced by a model. It also assumes the vector extension is already enabled in your database, which the previous chapter covered. Here you will learn wh5 min readINSERT and UPDATE statements. It also assumes you have enabled pgvector and created the items table from the earlier chapters. Here you will learn what a vector value looks like when you write it, how PostgreSQL validates it, and how to load and change 4 min readvector column (such as the items table from earlier chapters), and know that a distance metric turns two vectors into one number. Here you will learn what each pgvector operator computes, how to read its output, and where each one5 min readvector column like the one built earlier. The examples use this table:5 min readpsql, and have read the earlier chapters on the vector type, the distance ope7 min readvector column. It also assumes you know the difference between exact and approximate search from the previous chapter. The items table from earlier chapters is used throughout.5 min readORDER BY embedding <-> ... LIMIT k. It also assumes you know why approximate search trades recall for speed. IVFFlat is the older of the two approximate index types in pgvector. It builds quickly and uses little memory, but it ne4 min readvector column, run ORDER BY embedding <=> ... LIMIT n queries, and have built an HNSW or IVFFlat index at least once. You should also know that the operators <->, <=>, <#>, and <+> each compute a different distance.5 min readORDER BY embedding <=> ... LIMIT k query. It also assumes you know that approximate indexes can miss true neighbors. Here you will learn which settings are fixed when an index is built, which can change on every query,5 min readORDER BY embedding <=> ... LIMIT k query. It also assumes you know what EXPLAIN shows. Here you will see why adding a WHERE clause to an approximate vector query can return fewer rows than you asked for, and how to fix that5 min readvector type, the distance operators, and indexes, and that the items table from earlier chapters exists. You should also know basic Python and what a database connection an4 min readvector column, create HNSW and IVFFlat indexes, and match operator classes to operators. Here you will learn three other types that pgvector provides. They reduce storage and index size, or represent embeddings that are mostly zeros. The type names an4 min readhnsw.ef_search and ivfflat.probes. It covers the operational side: what an index build costs, which settings control it, and how to keep an index healthy as data changes.5 min read