1 a table scan is reading every record from the


1. A table scan is reading every record from the table in a sequential order to find the data that a query is looking for. If you have a table with millions of records then this kind of reading can cause very slow performance in SQL queries.There are different situation where a full table scan can cause poor performance in SQL statements,such as consider a query which does not have a "Where" clause to filter the recordswhich could appear in the result set, then the full table scan will be performed on such statements or consider a query which has a"Where" clause, but none of the columns in that "Where" clause match the leading column of an index on the table, then a full table scan will be performed (Oracle, 2008) or if there is no reasonably selection condition in the "Where" clause can also cause the full table scan which in turn slows down the performance of the SQL query.

Let us consider a SQL statement which can cause the full table scan.

SQL>Select productid, prodname

2  From Product

3  Whereproddescr like '%hard disk%';

Execution Plan

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

Plan hash value: 427209646

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

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

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

|   0 | SELECT STATEMENT  |         |    22 | 44924 |     5   (0)| 00:00:01 |

|*  1 |  TABLE ACCESS FULL| PRODUCT |    22 | 44924 |     5   (0)| 00:00:01 |

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

The above query is not very selective and could fetch millions of records on a large table by resulting the poor performance of the SQL statement. Also the "where" condition will try to match for each and every row of the "PRODUCT" table which will cause a full table scan. First of all the column specified in the where clause does not refer to index column nor it is a primary key field and a "LIKE" query with a leading wildcard cannot be optimized.

Table Joins.

a. How does the order of joins in an SQL statement affect the performance of the join?

b. 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?

c. Provide an example SQL join from Global Engineering or the Retail Company (but not both) and discuss the preferred join order.

Request for Solution File

Ask an Expert for Answer!!
PL-SQL Programming: 1 a table scan is reading every record from the
Reference No:- TGS0501662

Expected delivery within 24 Hours