Docsity

PrepIQ Indexes Ultimate Exam, Exams of Technology

Toggle sidebar
bg1
PrepIQ Indexes Ultimate Exam
**Question 1.** Which component of an index record directly points to the
actual data row in a non-clustered index?
A) Search key
B) Data block number
C) Pointer (row identifier)
D) Leaf node address
Answer: C
Explanation: In a non-clustered index, each entry contains the search key
and a pointer (row identifier) that references the exact data row.
**Question 2.** What is the primary advantage of using a B+ tree over a
plain B-tree for range queries?
A) Smaller tree height
B) All keys stored only at leaf level with linked leaves
C) Faster point lookups
D) Ability to store duplicate keys
Answer: B
Explanation: B+ trees keep all data records at the leaf nodes and link leaves
sequentially, making range scans efficient.
**Question 3.** In a hash index, which type of query can NOT be efficiently
supported?
A) Equality (=) on the hash key
B) BETWEEN on the hash key
C) IN list on the hash key
D) Exact match on the hash key
Answer: B
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e

Partial preview of the text

Download PrepIQ Indexes Ultimate Exam and more Exams Technology in PDF only on Docsity!

Question 1. Which component of an index record directly points to the actual data row in a non-clustered index? A) Search key B) Data block number C) Pointer (row identifier) D) Leaf node address Answer: C Explanation: In a non-clustered index, each entry contains the search key and a pointer (row identifier) that references the exact data row. Question 2. What is the primary advantage of using a B+ tree over a plain B-tree for range queries? A) Smaller tree height B) All keys stored only at leaf level with linked leaves C) Faster point lookups D) Ability to store duplicate keys Answer: B Explanation: B+ trees keep all data records at the leaf nodes and link leaves sequentially, making range scans efficient. Question 3. In a hash index, which type of query can NOT be efficiently supported? A) Equality (=) on the hash key B) BETWEEN on the hash key C) IN list on the hash key D) Exact match on the hash key Answer: B

Explanation: Hash indexes excel at equality searches; they cannot handle range predicates like BETWEEN because the hash function distributes values arbitrarily. Question 4. Bitmap indexes are most suitable for columns with which characteristic? A) High cardinality (many distinct values) B) Low cardinality (few distinct values) C) Frequently updated columns D) Variable-length string columns Answer: B Explanation: Bitmap indexes compress well when a column has few distinct values, enabling fast bitwise operations. Question 5. Which statement best describes a clustered index? A) It stores a separate copy of the data in leaf pages. B) It determines the physical order of rows in the table. C) It can be created on any column without restrictions. D) It always requires a unique key. Answer: B Explanation: A clustered index orders the table rows on disk according to the indexed key, making it the table’s storage order. Question 6. A non-clustered index differs from a clustered index in that it: A) Stores data rows in leaf pages. B) Changes the physical order of rows. C) Contains a pointer to the data rows. D) Can only be created on primary key columns.

Explanation: When a single-level index would be too large, a higher-level index points to lower-level index pages, forming an index hierarchy. Question 10. When creating a composite index on columns (A, B, C), which query can fully benefit from the index without additional lookup? A) WHERE C = 5 B) WHERE B = 3 AND C = 7 C) WHERE A = 2 AND B = 4 D) WHERE B = 4 Answer: C Explanation: Composite indexes follow the left-to-right prefix rule; the query must reference the leading column(s) in order. Question 11. Which SQL statement creates a unique, non-clustered index named idx_emp_email on the Email column of the Employees table? A) CREATE INDEX idx_emp_email ON Employees (Email) UNIQUE; B) CREATE UNIQUE INDEX idx_emp_email ON Employees (Email); C) CREATE NONCLUSTERED INDEX idx_emp_email ON Employees (Email) UNIQUE; D) ALTER TABLE Employees ADD UNIQUE INDEX idx_emp_email (Email); Answer: B Explanation: The syntax CREATE UNIQUE INDEX creates a unique, non-clustered index unless CLUSTERED is specified. Question 12. Which command removes an existing index named idx_sales_date from the Sales table? A) DROP INDEX idx_sales_date FROM Sales; B) DELETE INDEX idx_sales_date ON Sales; C) ALTER TABLE Sales DROP INDEX idx_sales_date;

D) DROP INDEX idx_sales_date; Answer: A Explanation: The DROP INDEX idx_name FROM table_name; syntax removes a specific index. Question 13. Primary key constraints automatically generate which type of index in most relational DBMSs? A) Bitmap index B) Full-text index C) Clustered index (if not already clustered) D) Non-clustered index only Answer: C Explanation: Most systems create a clustered index on the primary key unless the table already has a clustered index. Question 14. Which system catalog view in SQL Server lists all indexes on a database? A) sys.tables B) sys.indexes C) INFORMATION_SCHEMA.INDEXES D) sys.columns Answer: B Explanation: sys.indexes contains a row for each index defined on tables and views. Question 15. High selectivity of a column means: A) The column contains many duplicate values. B) The column has few distinct values.

A) The primary key of the parent table only. B) The foreign-key column in the child table. C) Both primary and foreign keys automatically. D) Only composite keys need indexing. Answer: B Explanation: Indexing the foreign-key column speeds up lookups when joining child rows to the parent table. Question 19. Logical fragmentation in an index occurs when: A) Index pages are out of order on disk. B) Index pages contain many empty slots due to deletions. C) The index tree height increases. D) Data pages are split unevenly. Answer: B Explanation: Logical fragmentation (or “hole” fragmentation) means the index has many sparsely filled pages, often after deletions. Question 20. Physical fragmentation of an index is best described as: A) Index pages stored non-contiguously on disk. B) Duplicate keys appearing in the index. C) Excessive depth of the B-tree. D) Index entries pointing to wrong rows. Answer: A Explanation: Physical fragmentation occurs when index pages are scattered across the storage medium, causing extra I/O. Question 21. A filtered (partial) index is useful when: A) All rows need to be indexed.

B) Only a subset of rows satisfies a frequently used predicate. C) The column has high cardinality. D) The table is a view. Answer: B Explanation: Filtered indexes store only rows meeting a WHERE clause, reducing size and maintenance cost. Question 22. Full-text indexes are primarily designed for: A) Exact numeric equality searches. B) Searching large text columns for keywords and phrases. C) Storing binary large objects (BLOBs). D) Indexing JSON data. Answer: B Explanation: Full-text indexes enable efficient keyword and phrase searching within large textual data. Question 23. Columnstore indexes are most beneficial for: A. OLTP workloads with many small transactions. B. OLAP workloads with large scans and aggregations. C. Indexing primary keys only. D. Storing image data. Answer: B Explanation: Columnstore indexes store data column-wise, optimizing compression and query performance for analytical (OLAP) queries. Question 24. A function-based index can be created on which of the following expressions? A) UPPER(LastName)

B) It can be created on nullable columns. C) It automatically creates a primary key constraint. D) It can be filtered. Answer: C Explanation: A unique index enforces uniqueness but does not automatically become a primary key; they are distinct objects. Question 28. When using the left-to-right prefix rule, a composite index on (Country, State, City) can efficiently serve which query? A) WHERE City = 'Paris' B) WHERE State = 'Texas' AND City = 'Dallas' C) WHERE Country = 'USA' AND City = 'Seattle' D) WHERE Country = 'Canada' AND State = 'Ontario' Answer: D Explanation: The query references the leading column Country and the next column State, satisfying the prefix rule. Question 29. Which of the following is a disadvantage of bitmap indexes on high-update tables? A) They consume excessive disk space. B) They cause locking and contention during DML operations. C) They cannot be used for equality predicates. D) They are not supported on primary keys. Answer: B Explanation: Bitmap indexes are not ideal for tables with frequent inserts/updates because each modification may need to update many bitmaps, leading to contention.

Question 30. In SQL Server, the DMV sys.dm_db_index_physical_stats is used to: A) List all indexes in the database. B) Show fragmentation statistics for indexes. C) Create a new index automatically. D) Display index usage counts. Answer: B Explanation: This dynamic management view returns size and fragmentation information for each index. Question 31. Which of the following best describes a “covering index” in MySQL’s InnoDB engine? A) An index that stores the full row data in leaf pages. B) An index that includes all columns referenced by a query, eliminating the need to read the table. C) An index that covers multiple tables via foreign keys. D) An index that automatically compresses data. Answer: B Explanation: A covering index contains all required columns, allowing the optimizer to satisfy the query using only the index. Question 32. When an index is created on a computed column, the underlying expression is: A) Stored as plain text in the index. B) Evaluated at query time, not stored. C) Persisted (materialized) if the column is defined as PERSISTED. D) Ignored during updates. Answer: C

Answer: B Explanation: The INDEX_ASC hint tells Oracle to use the given index with an ascending scan direction. Question 36. Which of the following is true about “index-only” scans? A) They always require a clustered index. B) They read data pages after reading the index. C) They retrieve all needed columns directly from the index. D) They are only possible with hash indexes. Answer: C Explanation: An index-only (covering) scan fetches all required columns from the index itself, avoiding table lookups. Question 37. What is the main purpose of the ALTER INDEX REBUILD command? A) Change the index’s column list. B) Convert a non-clustered index to clustered. C) Defragment the index and reset its fill factor. D) Drop and recreate the index automatically. Answer: C Explanation: Rebuilding an index reorganizes its pages, removes fragmentation, and can apply a new fill factor. Question 38. In a database that supports “included columns,” which statement is correct? A) Included columns become part of the index key. B) Included columns are stored only in leaf pages and do not affect index ordering. C) Included columns are duplicated in every index level.

D) Included columns prevent index compression. Answer: B Explanation: Included columns are stored in leaf pages for covering purposes but do not participate in the index’s sort order. Question 39. Which of the following best explains why a primary key on a VARCHAR column may be less efficient than on an INT column? A) VARCHAR columns cannot be indexed. B) String comparisons are more CPU-intensive and larger keys increase index size. C) INT columns require less disk space, but VARCHAR keys are automatically compressed. D) Primary keys must always be numeric. Answer: B Explanation: Variable-length strings increase index size and require more complex comparisons, leading to slower search performance. Question 40. When a query uses a predicate on a column with a low-cardinality index, the optimizer may choose to: A) Use the index because it always improves performance. B) Perform a full table scan instead, as the index selectivity is low. C) Convert the index to a bitmap automatically. D) Create a temporary index on the fly. Answer: B Explanation: Low-cardinality indexes often return many rows; the optimizer may deem a full scan cheaper. Question 41. Which of the following statements about “index maintenance” is FALSE?

Question 44. A “covering index” that includes columns (A, B) with B as an included column will have which ordering? A) Ordered by A only. B) Ordered by A and B. C) Unordered because B is included. D) Ordered by B only. Answer: A Explanation: Only key columns (A) determine order; included columns (B) are stored for lookup but do not affect sorting. Question 45. Which of the following is a typical use case for a “partial index” in PostgreSQL? A) Indexing every row in a large audit table. B) Indexing only rows where deleted = FALSE. C) Indexing a column that contains JSON data. D) Indexing a column with a default value. Answer: B Explanation: Partial indexes store a subset of rows satisfying a WHERE clause, often to exclude logically deleted rows. Question 46. In Oracle, a “bitmap join index” is used to: A) Speed up joins by storing pre-joined rows in a bitmap structure. B) Replace foreign-key constraints. C) Perform full-text searches on join columns. D) Create a clustered index on a view. Answer: A Explanation: Bitmap join indexes pre-compute the join result and store it as a bitmap, accelerating join queries on low-cardinality columns.

Question 47. Which of the following statements about “clustered columnstore indexes” in SQL Server is TRUE? A) They store data row-wise. B) They cannot be partitioned. C) They combine the benefits of clustering and columnstore compression. D) They require a primary key on every column. Answer: C Explanation: Clustered columnstore indexes store data in a columnar format while also defining the logical order of rows, merging both concepts. Question 48. When a query includes a predicate on a function of a column (e.g., LOWER(Name) = 'john'), an index can be used only if: A) The column is part of a primary key. B) A function-based index on LOWER(Name) exists. C) The database automatically rewrites the predicate. D) The column is defined as NOT NULL. Answer: B Explanation: The optimizer can use an index only if the exact expression is indexed. Question 49. In a B+ tree, the “fan-out” refers to: A) The number of keys per leaf node. B) The number of child pointers per internal node. C) The depth of the tree. D) The size of the root page. Answer: B

Answer: B Explanation: Sequential GUIDs produce an ordered key, making a B-tree (especially clustered) efficient for inserts. Question 53. A “reverse key” index in Oracle is used to: A) Store keys in descending order. B) Reduce contention on index leaf blocks for monotonically increasing keys. C) Enable full-text search on numeric columns. D) Create a bitmap index automatically. Answer: B Explanation: Reverse key indexes reverse the byte order of the key, distributing inserts across leaf pages and minimizing hot-spot contention. Question 54. Which of the following statements about “index hints” is correct? A) They guarantee that the optimizer will use the hinted index. B) They are ignored if the hinted index is invalid. C) They can only be used with primary keys. D) They are required for all queries that use indexes. Answer: B Explanation: If the hinted index does not exist or cannot be used, the optimizer ignores the hint and chooses an alternative plan. Question 55. In PostgreSQL, the EXCLUDE constraint internally creates which kind of index? A) B-tree B) GIST C) HASH

D) SP-GIST

Answer: B Explanation: EXCLUDE constraints rely on GiST indexes to enforce arbitrary exclusion rules. Question 56. Which of the following is a typical symptom of severe index fragmentation? A) Decreased CPU usage during queries. B) Faster index creation times. C) Increased logical reads per query. D) Automatic index compression. Answer: C Explanation: Fragmented indexes cause more page reads, raising logical I/O per query. Question 57. When creating a composite index on (OrderDate, CustomerID), which query can benefit from index seek on both columns? A) WHERE CustomerID = 10 AND OrderDate = '2023-01-01' B) WHERE OrderDate = '2023-01-01' AND CustomerID = 10 C) WHERE OrderDate = '2023-01-01' D) WHERE CustomerID = 10 Answer: C Explanation: The leftmost column (OrderDate) is used; the optimizer can seek on OrderDate. Adding CustomerID after OrderDate does not help unless both are in the predicate with the correct order. Question 58. In MySQL, the ANALYZE TABLE command primarily updates: A) Index definitions.