FDE ACADEMY · MODULE 02 · LESSON 04
The database is where it becomes a system
One PostgreSQL with a vector extension instead of two data stores, why the index is a recall decision rather than a speed decision, and the delete you must be able to run.
- Effort
- About two hours against a deployment you already have running.
- Skills
- postgresql · vector-databases · data-engineering
Free and self-paced. No certification is offered.
Before you startYou have the knowledge base from lesson 03 running with a loaded collection.
01One store, unless you can name the reason for two
A retrieval deployment needs to store documents, chunks, embeddings, users, permissions and logs. A relational database with a vector extension does all of it, in one place, with one backup, one restore, one access-control model and transactions across the lot.
A dedicated vector database is the right answer at a scale most organisational deployments never reach, and it is the wrong answer for a firm with a hundred thousand chunks. The cost of the second store is not licence money, it is the two systems that must agree about what has been deleted.
02Indexes are a recall decision
Approximate nearest-neighbour indexes trade recall for speed: they return a good set of neighbours quickly, not necessarily the best set. That trade is invisible until you evaluate, which is why lesson 03 came first. Build your baseline with exact search on a small collection, then measure again after adding the index and see what you gave up.
Then check the arithmetic on your own numbers. At a few tens of thousands of chunks, exact search is often fast enough, and an index you did not need is a source of surprising answers.
03Deletion is a database problem, and it is a promise
Your customer will eventually have to remove a client’s material: a matter closes, a contract ends, a person exercises a right. That means deleting the file, the extracted text, every chunk, every embedding, the cached answers, and whatever the logs kept. If that is several systems, deletion is a project each time.
Write the delete before you need it and run it on test data. A retention promise you cannot execute is worse than one you never made, and this is the point in the build where it is cheap to get right.
04Do this
PRACTICAL TASK
Move the state onto PostgreSQL and write the delete
Put documents, chunks and embeddings into one database, then write and test the single operation that removes one collection completely.
What you need
- The running knowledge base from lesson 03
- A test collection you can destroy
Steps
- 01
Follow the recipe’s pgvector step and its “move onto PostgreSQL and pgvector” step, in that order.
- 02
Inspect the tables. Find where a document, its chunks and its embeddings live, and how they refer to each other.
- 03
Write one transaction that removes a collection and everything derived from it. Run it against the test collection.
- 04
Prove it worked: search for a phrase that only appeared in that collection and confirm nothing comes back, then check the vector table row count.
- 05
Read the retention and logging compliance notes on the recipe and check your delete satisfies what they point at.
You are done when
- Documents, chunks and embeddings are in one database and you can draw the relationship between the three tables.
- One transaction removes a collection completely, and you have verified it by search and by row count.
- You can say what your deployment keeps after a delete — cached answers, logs, backups — and for how long.
05Where these facts live
This lesson does not restate anything that is already recorded with its evidence elsewhere on the site. These are the pages it leans on.
- pgvector
The vector extension the flagship recipe uses, with the documents this site watches for it.
- PostgreSQL
The single store behind documents, chunks, embeddings, users and logs in most of these recipes.
- Qdrant
The dedicated alternative, for when you can name the scale that justifies a second data store.
- Private internal document search
pgvector in a written-up design: the collection layout, the identity rules, and what the index costs to keep current.
Ticks are stored in your browser only. They are not sent anywhere, they are not attached to an account, and clearing your browser data removes them.