Domain 2: Develop AI Solutions by Using Azure Data Management Services (Part 3 of 3)
This lesson covers 4 exam topics: Vector Search and RAG in PostgreSQL, Connection Pooling with PgBouncer, Azure Managed Redis: Caching, Expiration, Invalidation, Vector Search and Semantic Caching in Redis. Each topic has a short video, then the notes: key facts, exam traps and what to check in the official docs.
1. Vector Search and RAG in PostgreSQL
Central question: How do you build RAG retrieval with metadata filters in PostgreSQL?
Facts
- Store embeddings in a
vector(n)column next to text and metadata. - Similarity:
ORDER BY embedding <=> $query LIMIT k(cosine distance);<->L2,<#>negative inner product. - Combine with WHERE filters (tenant, category, date); a partial index matching the WHERE condition helps.
- Generate embeddings with Azure OpenAI in the app (or the
azure_aiextension, general background).
RAG flow (design guidance)
- Chunk documents, embed, insert rows with metadata.
- Embed the question with the same model.
- Filter by metadata + order by distance, top k.
- Put chunks in the prompt with citations.
Exam traps
- Filtering after LIMIT in app code (misses results). Filter in SQL.
- Different embedding models for rows and queries.
- Returning chunks without source metadata.
2. Connection Pooling with PgBouncer
Central question: How do you handle many connections efficiently?
Facts
- Postgres uses a process per connection, so many idle connections are expensive.
- PgBouncer is built in to flexible server: enable with
pgbouncer.enabled = true(no restart), connect on port 6432 with the same host name. - Uses server connections only inside a transaction or active query; scales to 10,000 client connections.
- Default
pgbouncer.pool_mode= transaction; supports Microsoft Entra authentication. - Supported on General Purpose and Memory Optimized tiers.
Design guidance
Also pool in the app (driver pools), keep transactions short, avoid session-level state (temp tables, SET) in transaction mode, monitor active connections.
Exam traps
- Connecting to 5432 while expecting pooling.
- Session state in transaction pooling mode.
- Enabling PgBouncer on Burstable.
3. Azure Managed Redis: Caching, Expiration, Invalidation
Central question: How do you cache data correctly with Azure Managed Redis?
Facts
- Azure Managed Redis is built on Redis Enterprise (Redis 7.4.x); tiers Memory Optimized (8:1 memory:vCPU), Balanced (4:1), Compute Optimized (2:1), Flash Optimized (RAM + NVMe).
- Azure Cache for Redis Basic, Standard and Premium retire September 30, 2028; migrate to Azure Managed Redis.
- Cache-aside: read cache → on miss read store and populate; on update write store then invalidate the cache entry.
- Expiration (TTL) removes stale items; when full, the cache evicts (usually least recently used).
Commands (general background)
SET key value EX 300, GET, DEL (invalidate), EXPIRE, TTL.
Exam traps
- No TTL, so stale data lives forever.
- Updating the cache before the store.
- New build on Azure Cache for Redis instead of Azure Managed Redis.
4. Vector Search and Semantic Caching in Redis
Central question: How do you use Redis as a low-latency vector store?
Facts
- Vector search needs the RediSearch module; in Azure Managed Redis it must be enabled at creation (modules can't be added later).
- Index types: FLAT (exact, brute force; small sets) and HNSW (approximate, fast at scale); metrics include Euclidean, cosine, inner product.
- Use one embedding model consistently; index schema, dimensions and metric must match it.
- Common uses: RAG retrieval, semantic caching of LLM responses (LangChain integration tutorial).
Semantic cache (design guidance)
Embed the prompt → vector search the cache → if similarity above threshold, return the cached answer (with TTL) → else call the model and store the result. Saves tokens and latency for repeated questions.
Exam traps
- Creating the cache without RediSearch, then trying to add it.
- Threshold too loose, returning wrong cached answers.
- No TTL on cached LLM answers.
References
- AI-200 study guide — checked Oct 22, 2026
- Use pgvector — checked Oct 22, 2026
- Optimize pgvector performance — checked Oct 22, 2026
- PgBouncer — checked Oct 22, 2026
- What is Azure Managed Redis? — checked Oct 22, 2026
- Cache-aside pattern — checked Oct 22, 2026
- Retirement FAQ — checked Oct 22, 2026
- Vector similarity with Azure Managed Redis — checked Oct 22, 2026
Check your understanding
Cosine distance operator?Show answerHide answer
Answer
<=>.PgBouncer port?Show answerHide answer
Answer
6432.Pattern: check cache, then database?Show answerHide answer
Answer
Cache-aside.Module required for vector search?Show answerHide answer
Answer
RediSearch, enabled at creation.Restrict results to one tenant?Show answerHide answer
Answer
WHERE tenant_id = ... in the same query.