Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Database Engineer practice bank has an additional 769 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
A retail organization is deploying a semantic search application on AlloyDB for PostgreSQL using the vector (pgvector) extension. The database stores 5 million 768-dimensional product embeddings generated by text-embedding-005 in a vector(768) column, and queries rank results using cosine distance (<=>).
The architecture team has established the following requirements:
Which indexing strategy should the team implement?
HNSW index using vector_cosine_ops and tune the m and ef_construction parametersHierarchical Navigable Small World (HNSW) is a multi-layered, graph-based Approximate Nearest Neighbor (ANN) indexing algorithm supported by the vector (pgvector) extension in AlloyDB for PostgreSQL. It organizes stored embeddings into a navigable graph where queries perform a greedy search across connected nodes to quickly converge on the closest semantic neighbors.
HNSW delivers consistently fast query responses alongside high recall accuracy.HNSW is specifically well suited for higher-dimensional embeddings (such as 768 dimensions) and datasets scaling up to 10–20 million vectors when the index fits largely within the in-memory cache.vector_cosine_ops ensures the index matches the cosine distance operator (<=>) used in the application's SQL queries.m (maximum connections per node, defaulting to 16) and ef_construction (candidate list size during build, set higher than 2 * m) lets you directly balance recall against build cost.HNSW vector queries can be further accelerated by the columnar engine, offering up to 5x faster queries than standard PostgreSQL.HNSW does not depend on pre-computed centroids that can degrade as data distribution shifts.Compared to IVFFlat and IVF, HNSW trades higher memory consumption and longer build times for superior query speed and recall accuracy. Because the instance has ample RAM and off-peak build capacity, HNSW is the ideal choice for latency-sensitive, high-recall semantic search.
K-nearest neighbors (KNN) is the default vector search strategy used in AlloyDB for PostgreSQL when no vector index exists on the embedding column. It performs a brute-force calculation against every stored vector in the table to compute exact distances and return the precise top-k closest matches.
HNSW at 5 million rows.The table contained only tens of thousands of vectors and the application had strict 100% exact-match accuracy requirements where brute-force scan latency remained within acceptable limits.
A common misconception is that skipping an index is harmless if the table fits in RAM. Even in memory, computing 5 million 768-dimensional cosine distances per query creates severe compute bottlenecks compared to an HNSW ANN index.
IVFFlat index using vector_cosine_ops and tune the lists parameterInverted File Flat (IVFFlat) is a partitioning-based Approximate Nearest Neighbor (ANN) index provided by pgvector. It uses clustering to group similar vectors into a configured number of inverted lists (lists) during index creation, narrowing the search space at query time by probing only a subset of nearby clusters.
HNSW, IVFFlat generally exhibits slower query performance for a given recall target because it must linearly scan full, uncompressed vectors within the selected list partitions.IVFFlat requires probing more lists at query time, which directly increases query latency and undermines the primary user-facing performance goal.IVFFlat's main strengths—faster build times and smaller memory usage—address constraints that the architecture team explicitly does not have.HNSW graph.HNSW because it avoids iterative graph linking.lists tuning: Poorly chosen lists values or skewed data updates after clustering can degrade both recall and speed, often requiring periodic index rebuilds.The database operated under strict memory constraints or required rapid index rebuilds after frequent bulk data refreshes, and the application could tolerate slightly higher query latency or lower recall.
Students often assume IVFFlat and HNSW offer identical query speeds once indexed. In practice, HNSW provides a significantly better recall-versus-latency curve when sufficient RAM is available to hold the graph in memory.
IVF index using vector_cosine_ops with quantizer = 'SQ8' and tune the lists parameterAlloyDB's enhanced Inverted File (IVF) index extends standard pgvector clustering by supporting 8-bit scalar quantization (SQ8). Scalar quantization compresses high-dimensional floating-point vector components into compact 8-bit representations, reducing index memory consumption and enabling indexing for vectors with up to 8,000 dimensions.
SQ8 introduces quantization approximation, which results in some recall loss compared to unquantized HNSW graphs.SQ8 responds faster than the unquantized FLAT IVF option, graph-based HNSW still delivers faster query performance when the dataset fits in memory.SQ8 is needed here.FLAT limits.FLAT or HNSW indexes.FLAT IVF: Compressing vectors accelerates distance calculations during list scans at the expense of minor precision loss.The application stored very high-dimensional vectors (over 2,000 dimensions) or faced tight memory limits where reducing RAM usage outweighed minor recall loss.
When an HNSW index fits comfortably in memory for 768-dimensional embeddings, avoiding quantization preserves full vector precision during similarity calculations, maximizing recall accuracy alongside low query latency.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated