My Vector Database Would Fall Asleep Between My Trips A developer rebuilding a personal travel-planner app chose pgvector over Qdrant because Qdrant's free cloud tier suspends a cluster after a week of inactivity and deletes it after four weeks, which would leave the database asleep or gone between trips. The developer, whose app has one user and is used a few times a year, will store vectors as a table in the Postgres database already needed for trips, avoiding a second service to keep awake and a second bill. The developer noted pgvector's HNSW and IVFFlat indexes are approximate nearest-neighbour searches that can miss the exact best match, and said each listed weakness needed a fix before committing. In my last article, my weekend travel planner decided I love taxis https://pub.towardsai.net/my-travel-planner-decided-i-love-taxis-131e177af9c7 . One note about a taxi app in Sicily turned into a rule about me, and that was only one of eleven flaws the prototype showed me. At the end, I promised a choice: pgvector or Qdrant. This is that choice. The prototype kept my travel notes in Chroma, on my laptop. That was perfect for a weekend. But the rebuild needs a backend API and a website I can open on my phone in the middle of Porto. My laptop will be at home. So the notes need a home on a server, and the trips are already moving to Postgres. Two candidates were left. Put the vectors into Postgres with pgvector, or give them their own database in Qdrant. Let me be honest about my app’s traffic. 🙃 There’s one user: me. I travel a few times a year, not every week. Between trips, the planner can sit untouched for a month or more. And it’s a side project, so I don’t want to pay for any of it until it proves it’s worth it. Qdrant has a free cloud plan, and it’s a good one for trying things out. But its documentation is clear about one rule. Your database there is called a cluster, and if a free cluster isn’t used for a week, it’s suspended. If nobody reactivates it, it’s deleted after four weeks. Now picture my usage. Say I plan a trip, then don’t touch the app for six weeks. I open it at the airport… and my database is asleep. Or gone. Postgres is a different story, because I need it anyway. The rebuild moves the trips there, and the places and plans will follow. Wherever that database runs, it has to be awake whenever I open the app, or the planner can’t even list my trips. So keeping it awake is a problem I have to solve once, no matter where the vectors go. With pgvector, the notes become one more table in that same database. No second service to keep awake, no second bill. You might ask: why not run Qdrant myself, in Docker, next to Postgres? Qdrant is open source, so that would also be free. But it would be one more service to run, update and back up, for one user. With pgvector, the backups I already make for my trips cover the notes too. So I’m leaning towards Postgres. But I’m choosing mostly on price, so I want to know what I lose. I listed the weaknesses of pgvector for my case, and I didn’t want to commit until each one had a fix. To understand them, though, you need to know how the search finds a note in the first place. pgvector can search in two ways. By default, it does an exact search: it compares my question with every note and returns the true closest ones. That’s perfect, and it’s also slow once there are millions of rows. For speed, you add an index. The one I’ll use is HNSW, short for Hierarchical Navigable Small World. The name is a mouthful, but the idea is simple. When a note is saved, it gets linked to a few notes that are similar to it. Later, the search walks along those links instead of checking everything. Here’s a small example. Say I have 1,000 travel notes, and some of them are linked like this: I ask: “cozy café with a view” . It looked at around ten notes instead of a thousand. That web of links is called a graph. The “hierarchical” part means the real graph has layers. Think of a road trip: you take the highway to reach the right region, then small streets to find the exact café. The top layer is the highway, with few notes and long jumps. The lower layers have more notes and short steps. The walk above is what happens on one layer. And here’s the catch. If the perfect café note isn’t linked anywhere along that path, the walk never sees it. So HNSW is an approximate search: fast, and usually right, but not always. pgvector has a second index, IVFFlat, and it’s the same kind of thing. Both are ANN indexes approximate nearest neighbour : they skip most of the data to be fast, and accept that they might miss the very best match now and then. They’re just built differently: The pgvector docs say HNSW gives better query performance, while IVFFlat builds faster and uses less memory. One more detail made it easy for me: IVFFlat learns its buckets from the data that’s already in the table, so it should be built after the data is there. HNSW has no such training step and can be created on an empty table. My notes will grow slowly, a trip at a time, so HNSW it is. Now, the three weak spots. Why. HNSW first collects a fixed number of candidates, and only then applies the WHERE clause. That number is hnsw.ef search: how many candidates the search looks at, 40 by default. If only a few of those 40 match my filter, I get only a few results back, even when the table has plenty of matching rows that are just a little less similar to my question. The pgvector README gives a sharp example: if a condition matches 10% of the rows, then with the default of 40, only about 4 rows will match on average. Ask for 5, get 4. Or fewer. The easiest way I found to picture it is a cloakroom. Ten thousand people hang their jackets in one huge cloakroom. You ask the attendant for “the 5 red jackets that are mine”. Without iterative scans, the attendant grabs the 40 reddest jackets in the whole room and checks the name tags. None of them are yours. They come back and say, “Sorry, nothing found.” Your red jackets are in there, they just weren’t among the 40 reddest. With iterative scans, the attendant grabs 40 jackets, finds none of yours, and grabs the next 40. They keep going until they’ve found 5 of yours, or until they hit a limit and give up. You get your jackets. ✅ What maps to what: With only me in the app, every jacket is mine, so the user id filter can’t cause this. But the verdict filter can. If I ask “What did I like in Vienna?”, the 40 closest notes might all be Vienna cafés I didn’t enjoy. And once a second person uses the app, user id becomes a problem too. To be fair, this doesn’t hurt me today. With a few dozen notes, 40 candidates is nearly the whole table, so nothing gets lost. The trouble starts when the table grows well past 40 rows and the filter matches only a small share of them. That’s exactly where a growing travel journal is heading. Fix. pgvector 0.8.0 added iterative index scans. One setting turns them on: SET hnsw.iterative scan = relaxed order; SELECT id, titleFROM notesWHERE user id = 1 AND verdict = 'loved'ORDER BY embedding <= $1LIMIT 5; Now, if too few rows pass the filter, the search fetches more. The limit from the cloakroom is real too: hnsw.max scan tuples stops the search after 20,000 rows by default. There’s a second mode, strict order, which keeps the results in exact order by distance. relaxed order may mix up the order a little, but it finds more matches. If the order matters, you can sort the results again afterwards. Why. This is the price of keeping everything in one database. A heavy vector search uses the same CPU and RAM as “save trip” or “list places”. If searches get busy, the rest of the app can slow down, and the other way around. For one person planning a few trips a year, I’m not worried today. But I’d like to know the way out before I need it. Fix. There are three steps, from small to big: Why. Remember the café walk? If the best note isn’t linked along the path, HNSW misses it. That’s the trade: a little accuracy for a lot of speed. Fix. Measure first, then tune. The rebuild plans an evaluation set: my own questions, each with the notes that should come back. The metric is hit rate@5: how often the right note shows up in the top 5 results. If that number drops, I raise ef search, so the search looks at more candidates: SET hnsw.ef search = 100; More candidates means better results and slower queries. The eval set tells me where that trade stops paying off, so I’m not guessing. Here’s what I’m really giving up. Qdrant and other dedicated vector databases have search features built in, and often you just switch them on. With pgvector, you write them yourself in SQL. Two examples made this concrete for me. Filtering : In Qdrant, the extra data stored with each vector, like city or verdict, is called the payload. If you index a payload field, Qdrant applies the filter during the search, not after it. So the cloakroom problem from weak spot 1 doesn’t happen. For apps with many users, you can also mark user id with is tenant, and Qdrant keeps each user’s data together, so “only my notes” searches get faster. Hybrid search: Sometimes I search by meaning “cozy café with a view” , and sometimes by name, like a specific bakery, where keywords work better. Hybrid search runs both and merges the results, often with Reciprocal Rank Fusion RRF : a note scores higher the closer it is to the top of either list. In Qdrant, that’s a single request. In Postgres, I write it myself. The first part below searches by meaning, the second by keywords, and the last part merges the two lists with RRF: -- tsv is a tsvector column with the note's textWITH semantic AS SELECT id, RANK OVER ORDER BY embedding <= $1 AS rank FROM notes WHERE user id = $2 ORDER BY embedding <= $1 LIMIT 20 ,keyword AS SELECT id, RANK OVER ORDER BY ts rank cd tsv, q DESC AS rank FROM notes, plainto tsquery 'english', $3 AS q WHERE user id = $2 AND tsv @@ q ORDER BY ts rank cd tsv, q DESC LIMIT 20 SELECT COALESCE s.id, k.id AS id, COALESCE 1.0 / 60 + s.rank , 0 + COALESCE 1.0 / 60 + k.rank , 0 AS scoreFROM semantic sFULL OUTER JOIN keyword k ON s.id = k.idORDER BY score DESCLIMIT 5; It works, and I understand every line of it. But it’s longer, it’s mine to test, and it’s mine to fix. That’s the real cost of pgvector: the queries take more effort to write. pgvector, for now. Not because it’s better at vector search. Qdrant is built for exactly this, and it shows. I’m choosing Postgres because of my situation: one user, rare trips, no budget, and a free Qdrant cluster that would fall asleep between my trips. And each of the Postgres weak spots has a known fix: I’ll switch to Qdrant when one of these happens: the searches slow down the app even after a replica, the app gets real users and keeping each user’s notes apart becomes the main kind of search, or I catch myself writing my third hand-made hybrid query. And once I’m paying anyway, the sleeping rule stops mattering, because it only applies to the free tier. Choosing a database was the easy part. The bigger question is whether searching my notes makes the plans any better. In the next article, I’ll build an evaluation set, use it to pick an embedding model, and find out if my notes beat Claude with no memory at all. 😅 Until then, my notes move into Postgres, right next to my trips. And unlike a free cluster, they’ll still be awake when I land in Porto. Have you run vector search inside Postgres, or did you pick a dedicated vector database from the start? I’d love to hear what made you choose. My Vector Database Would Fall Asleep Between My Trips https://pub.towardsai.net/my-vector-database-would-fall-asleep-between-my-trips-65e61fc3cee9 was originally published in Towards AI https://pub.towardsai.net on Medium, where people are continuing the conversation by highlighting and responding to this story.