Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Indexes ► Sort data logically to improve the speed of searching and sorting operations. ► Provide rapid retrieval of specified rows from the table without.

Similar presentations


Presentation on theme: "1 Indexes ► Sort data logically to improve the speed of searching and sorting operations. ► Provide rapid retrieval of specified rows from the table without."— Presentation transcript:

1 1 Indexes ► Sort data logically to improve the speed of searching and sorting operations. ► Provide rapid retrieval of specified rows from the table without having to search the table. ► Improves data retrieval performance. ► Optimize access to data by using indexes and memory cache. ► Changes to table data (such as adding new rows, updating rows, or deleting rows) are automatically incorporated into all relevant indexes with complete transparency to the users.

2 2 Indexes in SQL ► Simple Index - create index on (column_name) ► Unique index – Two rows cannot have the same index value. create unique index on (column_name) ► Drop index – drop index ► Drop index – drop index

3 3 Searching Example Bolt Cam P#PnameColorP1NutRed P2BoltGreen P3ScrewBlue P4ScrewRed P5CamBlue P6CogRed FileIndex is on Pname Select * from parts where Pname = “Cam”

4 4 Sorting Example with demo Case # 1 select * from partstemp order by pname create index pnameindx on partstemp(pname) select * from partstemp order by pname alter table partstemp modify (pname constraint Not_Null_cons Not Null) select * from partstemp order by pname -------------------------------------------------------- Case # 2 – Composite Index select * from suppliertemp order by SID alter table suppliertemp modify (SID constraint Not_Null_const Not Null) create index sindx on suppliertemp (SID, sname) select * from suppliertemp order by SID, sname select * from suppliertemp order by sname, SID

5 5 Sorting ► Order by column should have NOT NULL constraint ► Index column should be in the Order by clause ► All the Order By column should be in composite index ► Order By columns should be of the same order of composite index ► At least one of the composite columns should have NOT NULL constraint

6 6 Indexing Techniques Indexing techniques provided by Oracle10g : B-Tree indexes, function- based indexes, partitioned indexes, index-organized tables, bitmap indexes, bitmap join indexes, clusters, hash clusters, domain indexes. Clusters - Clusters are groups of one or more tables physically stored together because they share common columns and are often used together. Because related rows are physically stored together, disk access time improves. See fig. on next slide. Hash Clusters - Hash clusters group table data in a manner similar to regular index clusters (clusters keyed with an index rather than a hash function). However, a row is stored in a hash cluster based on the result of applying a hash function to the row's cluster key value. All rows with the same key value are stored together on disk. Function-based Indexes - Allow access through a B-tree on a value derived from a function on the base data. Eg. - certain value derived from (sales price - discount) x quantity, where these were columns in the table.

7 7 Clustering

8 8 Indexes ► Disadvantages – Initial transaction performance may be high and takes up disk space ► Sorting – takes off CPU cost which is required to sort, performance is low. ► Small tables do not need indexes


Download ppt "1 Indexes ► Sort data logically to improve the speed of searching and sorting operations. ► Provide rapid retrieval of specified rows from the table without."

Similar presentations


Ads by Google