Domain 2: Develop AI Solutions by Using Azure Data Management Services (Part 2 of 3)
This lesson covers 4 exam topics: PostgreSQL: Connecting and Querying with SDKs, PostgreSQL Schema Design and Data Types, pgvector Indexes: IVFFlat, HNSW and DiskANN, Sizing PostgreSQL for Vector Workloads. Each topic has a short video, then the notes: key facts, exam traps and what to check in the official docs.
1. PostgreSQL: Connecting and Querying with SDKs
Central question: How do apps connect securely to Azure Database for PostgreSQL flexible server?
Facts
- Standard PostgreSQL drivers (e.g. Python psycopg) connect with host, database, user and sslmode=require.
- Microsoft Entra authentication: get a token with an Azure Identity credential for scope
https://ossrdbms-aad.database.windows.net/.defaultand pass it as the password; works with managed identity. - PgBouncer built-in pooling on port 6432 (topic 17).
Query practice (general background)
Parameterized queries (%s placeholders), short transactions, connection pools in the app, retry transient errors.
Exam traps
- Passwords in code when Entra tokens work.
- String-concatenated SQL.
- New connection per request without pooling.
2. PostgreSQL Schema Design and Data Types
Central question: How do you design tables for AI workloads?
Facts
- pgvector adds the vector(n) type; the extension name is vector (allowlist it in
azure.extensions, thenCREATE EXTENSION vectorper database). - ivfflat and hnsw can index up to 2,000 dimensions; larger vectors need dimensionality reduction.
- Partial indexes and partitioning reduce what queries scan; check plans with EXPLAIN (ANALYZE, BUFFERS).
Design guidance (general background)
| Need | Choice |
|---|---|
| Keys | bigint identity or uuid |
| Text | text (no length penalty) |
| Money | numeric, never float |
| Times | timestamptz |
| Flexible attributes | jsonb with GIN index |
| Embeddings | vector(n) matching the model |
| Filter columns | B-tree indexes on tenant, category, date |
Separate chunks from documents (one-to-many) and keep metadata columns for filtering and citations.
Exam traps
- float for money.
- Indexing every column (slower writes).
- vector dimensions not matching the embedding model.
3. pgvector Indexes: IVFFlat, HNSW and DiskANN
Central question: Which vector index, with which settings, keeps latency and compute low?
Facts
- No index = exact search (perfect recall, slow at scale). Indexes give approximate nearest neighbor search.
- IVFFlat: k-means lists; faster build, less memory, lower speed-recall trade-off; needs data before building (training). Start with
lists = rows/1000(≤1M rows) orsqrt(rows);ivfflat.probesstarts atlists/10orsqrt(lists). - HNSW: graph index; better speed-recall, more build time and memory; no training (can build on an empty table). Build params
m,ef_construction(e.g. 16, 64); queryhnsw.ef_search. - DiskANN (
pg_diskann, depends on vector): high recall, high QPS, low latency, fast builds, scales to billions. - Operator classes must match the query operator:
vector_l2_ops(<->),vector_cosine_ops(<=>),vector_ip_ops(<#>). - Tune with EXPLAIN; use partial indexes and partitioning; check parallel workers.
Exam traps
- Index built with cosine ops, query with
<->: index unused. - IVFFlat on an empty table.
- Raising probes/ef_search without measuring latency.
4. Sizing PostgreSQL for Vector Workloads
Central question: What compute, memory and storage do vector workloads need?
Facts
- Tiers: Burstable (CPU credits; dev/test, not sustained load), General Purpose, Memory Optimized (in-memory performance, high concurrency).
- HNSW builds take more memory than IVFFlat; DiskANN balances build speed and accuracy.
- PgBouncer is supported on General Purpose and Memory Optimized.
Sizing guidance (general background)
| Resource | Why it matters |
|---|---|
| Memory | Keep vector indexes in RAM; raise maintenance_work_mem for index builds |
| vCores | Parallel index builds and concurrent queries |
| Storage / IOPS | Index and table size; faster storage for larger-than-memory sets |
| Dimensions | 1536 floats ≈ 6 KB per row; halve with smaller models or reduction |
Exam traps
- Burstable for production vector search.
- Index larger than memory with no plan.
- Scaling compute when a missing index is the cause (check EXPLAIN first).
References
- AI-200 study guide — checked Oct 22, 2026
- Connect with Python — checked Oct 22, 2026
- Connect with managed identity — checked Oct 22, 2026
- Use pgvector — checked Oct 22, 2026
- Optimize pgvector performance — checked Oct 22, 2026
- Use DiskANN — checked Oct 22, 2026
- Compute options — checked Oct 22, 2026
Check your understanding
Password field with Entra auth?Show answerHide answer
Answer
The access token.Type for embeddings?Show answerHide answer
Answer
vector(n).Build an index before loading data?Show answerHide answer
Answer
HNSW (no training step).Tier for large in-memory vector indexes?Show answerHide answer
Answer
Memory Optimized.Token scope?Show answerHide answer
Answer
ossrdbms-aad.database.windows.net/.default.