{"slug": "my-vector-database-would-fall-asleep-between-my-trips", "title": "My Vector Database Would Fall Asleep Between My Trips", "summary": "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.", "body_md": "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.\n\nAt the end, I promised a choice: pgvector or Qdrant. This is that choice.\n\nThe 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.\n\nTwo candidates were left. Put the vectors into Postgres with pgvector, or give them their own database in Qdrant.\n\nLet me be honest about my app’s traffic. 🙃\n\nThere’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.\n\nQdrant 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.\n\nNow 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.\n\nPostgres 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.\n\nYou 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.\n\nSo 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.\n\nTo understand them, though, you need to know how the search finds a note in the first place.\n\npgvector 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.\n\nFor 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.\n\nHere’s a small example. Say I have 1,000 travel notes, and some of them are linked like this:\n\nI ask: *“cozy café with a view”*.\n\nIt looked at around ten notes instead of a thousand.\n\nThat 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.\n\nAnd 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.\n\npgvector 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.\n\nThey’re just built differently:\n\nThe 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.\n\nNow, the three weak spots.\n\n**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.\n\nThe 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.\n\nThe easiest way I found to picture it is a cloakroom.\n\nTen thousand people hang their jackets in one huge cloakroom. You ask the attendant for “the 5 red jackets that are mine”.\n\n**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.\n\n**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. ✅\n\nWhat maps to what:\n\nWith 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.\n\nTo 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.\n\n**Fix.** pgvector 0.8.0 added iterative index scans. One setting turns them on:\n\n```\nSET hnsw.iterative_scan = relaxed_order;\nSELECT id, titleFROM notesWHERE user_id = 1  AND verdict = 'loved'ORDER BY embedding <=> $1LIMIT 5;\n```\n\nNow, 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.\n\nThere’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.\n\n**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.\n\nFor 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.\n\n**Fix.** There are three steps, from small to big:\n\n**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.\n\n**Fix.** Measure first, then tune.\n\nThe 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:\n\n```\nSET hnsw.ef_search = 100;\n```\n\nMore candidates means better results and slower queries. The eval set tells me where that trade stops paying off, so I’m not guessing.\n\nHere’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.\n\nTwo examples made this concrete for me.\n\n**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.\n\n**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.\n\nIn 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:\n\n```\n-- 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;\n```\n\nIt 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.\n\npgvector, for now.\n\nNot 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.\n\nAnd each of the Postgres weak spots has a known fix:\n\nI’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.\n\nChoosing a database was the easy part. The bigger question is whether searching my notes makes the plans any better.\n\nIn 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. 😅\n\nUntil 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.\n\nHave 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.\n\n[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.", "url": "https://wpnews.pro/news/my-vector-database-would-fall-asleep-between-my-trips", "canonical_source": "https://pub.towardsai.net/my-vector-database-would-fall-asleep-between-my-trips-65e61fc3cee9?source=rss----98111c9905da---4", "published_at": "2026-11-18 14:31:02+00:00", "updated_at": "2026-11-18 14:44:12.568540+00:00", "lang": "en", "topics": ["ai-tools", "ai-products"], "entities": ["pgvector", "Qdrant", "Postgres", "Chroma", "HNSW", "IVFFlat"], "also_reported_by": [], "takeaway": "For a low-traffic app, storing embeddings in pgvector inside an existing Postgres instance avoids a separate vector service whose free tier suspends after 7 idle days and deletes after 4 weeks, at the cost of approximate HNSW or IVFFlat search that can miss the true nearest match.", "recommendation": {"advice": "If your app is idle for long stretches, put vectors in the Postgres you already run via pgvector instead of a free vector-DB tier that suspends after 7 days and deletes after 4 weeks.", "playbook": "rag-retrieval", "playbook_url": "https://wpnews.pro/playbooks/rag-retrieval"}, "alternates": {"html": "https://wpnews.pro/news/my-vector-database-would-fall-asleep-between-my-trips", "markdown": "https://wpnews.pro/news/my-vector-database-would-fall-asleep-between-my-trips.md", "text": "https://wpnews.pro/news/my-vector-database-would-fall-asleep-between-my-trips.txt", "jsonld": "https://wpnews.pro/news/my-vector-database-would-fall-asleep-between-my-trips.jsonld"}}