# Problems 29–32 are based on the following query: SELECT CUS_CODE, MAX(LINE_UNITS*LINE_PRICE) FROM CUSTOMER NATURAL JOIN INVOICE NATURAL JOIN LINE WHERE CUS_AREACODE = '615' GROUP BY CUS_CODE; How would you rewrite the query to ensure that the index you created in Problem 31 is used?

### Database Systems: Design, Implemen...

12th Edition
Carlos Coronel + 1 other
Publisher: Cengage Learning
ISBN: 9781305627482

Chapter
Section

### Database Systems: Design, Implemen...

12th Edition
Carlos Coronel + 1 other
Publisher: Cengage Learning
ISBN: 9781305627482
Chapter 11, Problem 32P
Textbook Problem
1 views

## Problems 29–32 are based on the following query: SELECT CUS_CODE, MAX(LINE_UNITS*LINE_PRICE) FROM CUSTOMER NATURAL JOIN INVOICE NATURAL JOIN LINE WHERE CUS_AREACODE = '615' GROUP BY CUS_CODE; How would you rewrite the query to ensure that the index you created in Problem 31 is used?

Program Plan Intro

Indexes:

• Indexing is a technique that is used in SQL for optimizing the performance.
• Indexes are used when a small set of rows needs to be selected from the table that is large in size.
• The selection of rows is made by specifying conditions.

The query of problem 29:

SELECT CUS_CODE, MAX(LINE_TOTAL)

FROM CUSTOMER NATURAL JOIN INVOICE NATURAL JOIN LINE

WHERE CUS_AREACODE = ‘615’

GROUP BY CUS_CODE;

Index creation for the attribute “CUS_AREACODE”:

The index for the given query is generated with the following name “CUS_MYNDX1”:

CREATE INDEX CUS_MYNDX1 ON CUSTOMERCUS_AREACODE);

### Explanation of Solution

Rewriting the query based on the index created:

• It is recommended to use the INDEX optimizer hint.
• Special instructions that are embedded inside the SQL command test for the optimizer is called as optimizer hints.
• They are three kinds of hint namely:
• ALL_ROWS
• It minimizes the overall time of the execution by instructing the optimizer.
• FIRST_ROW
• It minimizes the need for executing the first set of rows by instructing the optimizer...

### Still sussing out bartleby?

Check out a sample textbook solution.

See a sample solution

#### The Solution to Your Study Problems

Bartleby provides explanations to thousands of textbook problems written by our experts, many with advanced degrees!

Get Started

Find more solutions based on key concepts
How is an incident response plan different from a disaster recovery plan?

Principles of Information Security (MindTap Course List)

What is the main benefit of offhand abrasive machining or grinding?

Precision Machining Technology (MindTap Course List)

Crystal tableware glass that sparkles is sought after by many people as a sign of affluence. This crystal commo...

Engineering Fundamentals: An Introduction to Engineering (MindTap Course List)

Explain who might use a USB flash drive, and for what purpose.

Enhanced Discovering Computers 2017 (Shelly Cashman Series) (MindTap Course List)

If your motherboard supports ECC DDR3 memory, can you substitute non-ECC DDR3 memory?

A+ Guide to Hardware (Standalone Book) (MindTap Course List)

What is the purpose of postheating the metal after welding?

Welding: Principles and Applications (MindTap Course List)