QuestionQ107

VerifiedTuning SQL Statements

You administer a 19c database using the default optimizer settings.

This statement is extensively used as a subquery in the application queries:

SELECT city_id FROM sh2.sales WHERE city_id=:B1  

You observe that these queries often perform poorly and therefore run:

SELECT city_id,COUNT(*) FROM sh2.sales GROUP BY city_id;  

Review the results:

Question Image

No index exists on the CITY_ID column.

Which two options improve performance?

Choose two
Explanation

A frequency histogram records the highly nonuniform CITY_ID distribution, allowing accurate selectivity and cardinality estimates for equality predicates. An index on CITY_ID enables efficient retrieval for rare city values, while the optimizer can avoid it for the overwhelmingly common value when a full scan is less costly. In Oracle Database 19c, adaptive plans are enabled by default, and a SQL Profile supplies auxiliary statistics rather than enforcing a specific execution plan.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!