nerdexam
Oracle

1Z0-883 · Question #107

Consider the query: Mysql> SET @run = 15; Mysql> EXPLAIN SELECT objective, stage, COUNT (stage) FROM iteminformation WHERE run=@run AND objective='7.1' GROUP BY objective,stage ORDER BY stage; The…

The correct answer is B. Drop the run_2 index because it has caused a conflict in the choice of key for this query. See the full explanation below for the reasoning.

Question

Consider the query:

Mysql> SET @run = 15; Mysql> EXPLAIN SELECT objective, stage, COUNT (stage) FROM iteminformation WHERE run=@run AND objective='7.1' GROUP BY objective,stage ORDER BY stage; The iteminformation table has the following indexes; Mysql> SHOW INDEXES FROM iteminformation:

This query is run several times in an application with different values in the WHERE clause in a growing data set. What is the primary improvement that can be made for this scenario?

Exhibit

1Z0-883 question #107 exhibit

Options

  • AExecute the run_2 index because it has caused a conflict in the choice of key for this query.
  • BDrop the run_2 index because it has caused a conflict in the choice of key for this query.
  • CDo not pass a user variable in the WHERE clause because it limits the ability of the optimizer to use indexes.
  • DAdd an index on the objective column so that is can be used in both the WHERE and GROUP BY operations.
  • EAdd a composite index on (run,objective,stage) to allow the query to fully utilize an index.

How the community answered

(40 responses)
  • A
    10% (4)
  • B
    83% (33)
  • D
    5% (2)
  • E
    3% (1)

Community Discussion

No community discussion yet for this question.

Full 1Z0-883 Practice