Create a sql statement and execute the same in sqlplus

Assignment Help Database Management System
Reference no: EM13192822

1. Not having an appropriate index can cause a full table scan while performing the select statement by using a non-index field in the WHERE clause. Such queries will increase the logical read of the table and increase the disk input/output calls, i.e because such SQL statement will performs a row by row search to find the data that a query is looking for. For example consider a SQL statement and execute the same in SQLPLUS with the Explain plan option.

setautotracetraceonly explain

Select * from customer

Where Custlname = 'Dobson';

Execution Plan

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

Plan hash value: 2844954298

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

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

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

|   0 | SELECT STATEMENT  |          |     7 |   910 |   171   (1)| 00:00:03 |

|*  1 |  TABLE ACCESS FULL| CUSTOMER |     7 |   910 |   171   (1)| 00:00:03 |

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

This query will perform the full table scan on "CUSTOMER" table, because in the where condition we are using the non-index column "CUSTLNAME".

Now consider another example where we use Index column in our where condition.

setautotracetraceonly explain

Select * from customer

Where CustID = 98;

Execution Plan

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

Plan hash value: 908218400

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

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

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

|   0 | SELECT STATEMENT            |            |     1 |   130 |     0   (0)| 00:00:01 |

|   1 |  TABLE ACCESS BY INDEX ROWID| CUSTOMER   |     1 |   130 |     0   (0)| 00:00:01 |

|*  2 |   INDEX UNIQUE SCAN         | CUSTOMERPK |     1 |       |     0   (0)| 00:00:01 |

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

This query will perform the Index unique scan on index "CUSTOMERPK" and will perform the table access by Index rowid.  Even we can see the execution time, CPU usage and cost difference between both the queries based on the Index usage.

One of the factor that can cause the problem by having too many index are,

For example consider a table "customerorderitem" in retaildba. This table is modified very often on daily basis, as many customers will be ordering the products or they will be returning the purchased product. If such tables contains too many indexes then this could cause a slow performance problem, i.e. because for every data modification in that table, each index needs to be updated. Which in turn will use more CPU, more memory and more I/O operation. But if any table is modified less often, then having more indexes most likely won't be a problem.

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. This is because most RDBMS's have query optimizers that use those statistics to figure out if using an index is worth or not. The use of statistic will quickly determine which execution plan might product the fastest and most efficient execution plan.And if those statistics are not available, then the RDBMS may wrongly determine that doing a full table scan is more efficient than using an index.(Larsen,2013)

Reference no: EM13192822

Questions Cloud

Compute the change in the entropy of the universe : calculate the change in the entropy of the universe between the time that the contents of the glass enter the lake and when thermal equilibrium is subsequently restored. State any approximations made in your calculation.
Develop a swot analysis on the viability : Develop a SWOT analysis on the viability of upgrading to Windows 8 for the organization as a whole and provide a detailed upgrade plan for the organization, including the sales staff.
State what is the percent abundance of each isotope : Copper has two naturally occurring isotopes,63Cu (isotopic mass 62.9396 amu) and 65Cu (isotopic mass 64.9278 amu). If copper has an atomic mass of 63.546 amu, what is the percent abundance of each isotope?
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.

Reviews

Write a Review

Database Management System Questions & Answers

  Create the database using three tables

Create the database using three tables: one for student information, one for advisor information, and one for department information.

  What is meant by data independence

What is meant by data independence? Explain your answer and identify two benefits of separating application software from the database management system.

  Explain steps of process in increasing cardinalities

When increasing cardinalities from 1:N to N:M, which of the given steps are included in process the order of steps listed below is not relevant, only steps themselves?

  Explain what information is available in relational database

Explain what information is available from relational database containing one relation with attributes Name, Employee identification number, and Address which is not available.

  Worst-case performance of the fifo

Construct a scenario leading to the worst-case performance of the FIFO buffer replacement policy - determine if it is conflict serializable or not

  Design update trigger on part table which raises error

Design the Update trigger on Part table which raises an error string if Count field of updated row has a higher value than value prior to Update.

  Baxter aviation database

ER diagram for the Baxter Aviation database

  Construct a query that can be used on a report

Construct a query that can be used on a report for determining how many days the customer's invoice will require payment if total amount due is within 45 days. Provide a copy of your working code as part of the paper.

  Oracle having multiple group functions in same select list

Can Oracle have multiple group functions in the same SELECT list of query (i.e can we do a COUNT and AVG)? Let us assume we wanted to find lowest, highest, average.

  Design er schema to keep track of information of votes

Design an er schema for keeping track of information about votes taken in the U.S. House of Representatives during the current two year congressional session.

  Difference between manufacturing and service industries

Discuss whether the ERP software is mostly suitable for manufacturing companies or whether it can be used in service industries also.

  Sketch dfsa for identifiers-contain only letters and digits

Sketch a DFSA for identifiers which contain only letters and digits, where identifier should have at least one letter, but it need not be first character.

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