Question 1
Q1A financial services company needs to run frequent, high-performance queries against a large transaction table. The queries filter transactions based on the year and month of the transaction timestamp, which is stored in a TRANSACTION_TS column of data type TIMESTAMP. The current query uses WHERE YEAR(TRANSACTION_TS) = ? AND MONTH(TRANSACTION_TS) = ?, which results in a full table space scan. How should the DBA improve the performance of these queries?
Show answer & explanation
Correct answer: B
Creating an index on expressions allows Db2 to build an index based on the result of the functions. When the query's WHERE clause exactly matches the expressions defined in the index, the optimizer can use this index for direct access, avoiding a costly table space scan and significantly improving performance.