CompTIA DataSys+ (DS0-002) free question 6 / 10 · Domain 3: Database Management and Maintenance
The planner badly misjudges the number of rows returned when two correlated columns are used together in a filter. Which command lets the DBA give it better information?
- A statement that creates an extended statistics object
- A statement that defines a stored query over the columns
- A statement that defines a namespace for the table
- A statement that defines a login for the analysts
Show the answer and explanation
Answer: A
Why this is correct
The CREATE STATISTICS page says the command creates a new extended statistics object tracking data about the specified table, foreign table or materialized view. Extended statistics can describe several columns together, which is what the planner lacks when columns are correlated. The source reads: "CREATE STATISTICS will create a new extended statistics object tracking data about the specified table, foreign table or materialized view." The page continues: "The statistics object will be created in the current database and will be owned by the user issuing the command." Source page: CREATE STATISTICS, section "Description".
Why the other options are wrong
"A statement that defines a stored query over the columns" … A view does not change what the planner knows about correlated columns.
"A statement that defines a login for the analysts" … Roles control access. They do not provide statistics to the planner.
"A statement that defines a namespace for the table" … A schema is a namespace and has no effect on row estimates.
Key points
Extended statistics improve estimates for correlated columns.