What problems could be caused by not having indexes

Assignment Help Database Management System
Reference no: EM13192819

The order in which the tables in your queries are joined can have an effect on the query performs. If your query is joining all the large tables first and then joins to a smaller table, then this can cause a lot of unnecessary processing. The join order in each step means that the fewest number of rows are being returned to the next step, which in turn makes query performance better. Usually DBA's will try to find the best possible access method of the tables by performing the Explainplan on the query or by verifying the optimizer statistics. They also try to optimize the SQL workload by identifying the proper indexesfields in the "Where" clause for joining the tables. Before applying WHERE clause, the DBA's will always try to provide the best suited condition in "ON" condition while performing the Join, this will filter the data and reduce the join result itself. The subsequent join conditions will be executed with filtered data which makes better performance. After that only WHERE condition will apply filter conditions.They even try to eliminate the unnecessary large full table scan.

Let us consider the below Join query. Here Explain Plan will show how the statements are executed and it also shows the number of rows performed and the cost and CPU time taken. It produces the final record set of 665 rows.

setautotracetraceonly explain

Select P.ProductID, PS.ProductID, COL.ProductID

From Customerorderitem COL

Inner Join ProductSupplier PS

On COL.ProductID = PS.ProductID

Inner Join Product P

On COL.ProductID=  P.ProductID

Execution Plan

----------------------------------------------------------

Plan hash value: 1711654722

 

--------------------------------------------------------------------------------------------

| Id  | Operation              | Name              | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT       |                   |  4882 |   185K|    11  (10)| 00:00:01 |

|   1 |  NESTED LOOPS          |                   |  4882 |   185K|    11  (10)| 00:00:01 |

|*  2 |   HASH JOIN            |                   |  4882 |   123K|    11  (10)| 00:00:01 |

|   3 |    INDEX FAST FULL SCAN| PRODSUPPLPK       |   288 |  3744 |     3   (0)| 00:00:01 |

|   4 |    TABLE ACCESS FULL   | CUSTOMERORDERITEM |  4882 | 63466 |     7   (0)| 00:00:01 |

|*  5 |   INDEX UNIQUE SCAN    | PRODUCTPK         |     1 |    13 |     0   (0)| 00:00:01 |

--------------------------------------------------------------------------------------------

 

 

After modifying the Join order, executed the query with Explain Plan and it executed with little less Cost than the previous query. It even reduced the number of rows processed based on the Nested loop of table "Productsupplier" and "Product"which returned 288 rows.It also produces the final record set of 665 rows. This Join order is preferred over the first query.

 

setautotracetraceonly explain

 

Select  P.ProductID, PS.ProductID, COL.ProductID

From Customerorderitem COL

Inner Join Product P

On COL.ProductID=  P.ProductID

Inner Join ProductSupplier PS

On P.ProductID = PS.ProductID;

 

 

Execution Plan

----------------------------------------------------------

Plan hash value: 862510404

 

--------------------------------------------------------------------------------------------

| Id  | Operation              | Name              | Rows  | Bytes | Cost (%CPU)| Time     |

--------------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT       |                   |  4882 |   185K|    11  (10)| 00:00:01 |

|*  1 |  HASH JOIN             |                   |  4882 |   185K|    11  (10)| 00:00:01 |

|   2 |   NESTED LOOPS         |                   |   288 |  7488 |     3   (0)| 00:00:01 |

|   3 |    INDEX FAST FULL SCAN| PRODSUPPLPK       |   288 |  3744 |     3   (0)| 00:00:01 |

|*  4 |    INDEX UNIQUE SCAN   | PRODUCTPK         |     1 |    13 |     0   (0)| 00:00:01 |

|   5 |   TABLE ACCESS FULL    | CUSTOMERORDERITEM |  4882 | 63466 |     7   (0)| 00:00:01 |

 Indexes. Consider the Global Engineering and the Retail Company databases in your answers to these questions.

a. What problems could be caused by not having appropriate indexes?

b. What problems could be cause by having too many indexes?

c. What do database statistics contribute to defining appropriate indexes?

Reference no: EM13192819

Questions Cloud

State methanol burns in air according to the equation below : Methanol burns in air according to the equation below. How many grams of methanol can be burned by 10 grams of oxygen?
Create a sql statement and execute the same in sqlplus : Statistics can be created on tables, indexes columns and as well as on the individual columns. But, if for some reason table or index statistics have not been updated, then this may result in a full table scan.
State what temperature is needed to double the equilibrium : What temperature is needed to double the equilibrium constant from its value at 298 K? What temperature is needed to increase the equilibrium constant by a factor of 10? What if the standard enthalpy change were 20.0 kJ?
State what actions should an exposed person : What actions should an exposed person take during the immediate aftermath of the explosion? D. Lastly, if radioactive material is involved in a disaster incident such as this and there is a fire ongoing in the area where the container is located, ..
What problems could be caused by not having indexes : What problems could be caused by not having appropriate indexes and what problems could be cause by having too many indexes?
Depict correlation diagram the homo of allyl anion : draw correlation diagram the HOMO of allyl anion and the LUMO of ethylene and comment on the symmetry match of the two.
How much does the chemical potential of each molecule : Consider one mole of a monatomic ideal gas at 300 K that udergoes a free expansion from a volume of 1m^3 to 10 m^3. a). How much does the chemical potential of each molecule in the gas change?
How does the order of joins in an sql statement : How does the order of joins in an SQL statement affect the performance of the join and what can the DBA do to determine the preferred order of joins for an SQL statement that includes the join of at least three tables?
Define amino acid in an ion exchange chromatography column : particular amino acid in an ion exchange chromatography column. What is the peak width after the amino acid has migrated 100 cm?

Reviews

Write a Review

Database Management System Questions & Answers

  Potential sales and department store transactions

Identify the potential sales and department store transactions that can be stored within the database and design a database solution and the potential business rules that could be used to house the sales transactions of the department store.

  Database for university keep track of its course offerings

Assume you are making a database to help university keep track of its course offerings. You might have following entities in database, as they are distinct items in real life.

  Explaining emp table does not have assigned primary key

Developers have noticed that EMP table doesn't have an assigned primary key. EMP_ID column has been selected to be the primary key.

  A university library database records

A university library database records information about books; for each book, it records the book isbn number (which is unique), and the book name. In addition, it records which books have been checked out

  Compute canonical cover for set of functional dependencies

Compute a canonical cover for the above set of functional dependencies (show each step of your derivation with an explanation).

  Determine columns that make up the primary key

Carry out the following tasks below by using the correct SQL statements. Create the statements in Oracle by using the following steps (SQL > SQL commands > Enter Command). Determine the columns that make up the primary key of the l_lunch_items tabl..

  Draw an entity relationship diagram for the system

Draw an Entity Relationship diagram for the system and Identify the table design for the database displaying all the fields/attributes. Ensure that all tables are in 3NF. You also need to identify the primary keys and foreign keys, where applicable..

  Define a data flow in bus information system

Name four attributes that you can use to define a data flow in the bus information system. Name four attributes that you can use to define a data store in the bus information system.

  Types of relationships in a design model of a database

There are many kinds of relationships in a design model of a database. Why is it important to classify each of these types in an ERD Model?

  Explain data for each candidate of eight constituencies

supplies % of votes each candidate is likely to receive, based on popularity rating. Actual number of votes received is that percentage of General votes. You should enter data for each candidate in each of the eight constituencies.

  Choose a data storage problem of storing data in database

You should choose a data storage problem of your interest and identify the different pieces of data that should be stored in database.

  Characteristics of database

Describe the database and describe the four characteristics of the database? Explain the Relational Database and generate a relational database for five employees.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd