Internal Schema Design,Performance and Indexing.ppt
《Internal Schema Design,Performance and Indexing.ppt》由会员分享,可在线阅读,更多相关《Internal Schema Design,Performance and Indexing.ppt(53页珍藏版)》请在麦多课文档分享上搜索。
1、Internal Schema Design, Performance and Indexing,CS2312,Internal Schema Design,Data Blocks,Oracle manages data in datafiles as data blocks the smallest unit of I/O used by a database. the smallest units of storage that Oracle can use or allocate.,In contrast, at the physical, operating system level,
2、 all data is stored in bytes. Each operating system has what is called a block size. Oracle requests data in multiples of Oracle data blocks, not operating system blocks. Set the data block size for each Oracle database when you create the database as a multiple of the operating systems block size w
3、ithin the maximum (port-specific) limit to avoid unnecessary I/O.,Performance Profiling,Query Profilefrequency of certain querieshit rate on relationscertain relations used togetherselection attributes Update Profiledynamic or statichit rate of certain updatespredictablepre-fetch strategiesAnalysis
4、and Monitoring using tuning tools,Performance: Joins with Composite FK.,Flight(flightcode, ukairport,holairport, depday, deptime.) Hotel(hotelid, hotelname,.) GenericPackage(flightcode, hotelid, reservedrooms, reservedseats) SpecificPackage(flightcode, hotelid, depdate,availseats,availrooms, ) Booki
5、ng(bookingid, contact, flightcode, hotelid, depdate, noofpeople,noofrooms,)GenericPackage(gpackid,flightcode, hotelid, reservedrooms, reservedseats) SpecificPackage(spackid,gpackid, depdate, availseats, availrooms, ) Booking(bookingid, contact, spackid, noofpeople,noofrooms,),Performance: Frequent J
6、oins,Department,Staff,worksfor,deptno,roomno,staffno,staffname,1,m,Dept(deptno, deptname)Staff(staffno, staffname, roomno, deptno),deptname,1. Denormalise to 2NF,Replicate attribute valuesStaff(staffno, staffname, roomno, deptno, deptname) staffno staffname, roomno deptno deptname,2. Physically stor
7、ing a file resulting from a join,Materialised View Update integrity management,File Organisation,Organisation of the data of a file into records, blocks and access structuresOrganisation Unordered records Ordered records Hashing,File Organisation: Unordered Records,Place records in the order they ar
8、e inserted. New records inserted at the end of the file HEAP / PILE,File Organisation: Ordered Records,Physically order the records of a file on disk based on values of one of the fields ordering field / ordering key,Overflow Blocks,3. Inter-file clustering,Store records that are logically related a
9、nd frequently used together physically close together on disk,cluster applied across multiple files e.g. frequently access depts with their staffTherefore interleave Dept and Staff,1, Comp Sci,10, Goble, 2.82,23, Paton, 2.83,2, Maths,31, Smith, 1.100,49, Leuder, 1.23,Oracle Inter file Clustering,Cre
10、ate a cluster named PERSONNEL with the cluster key column DEPTNO CREATE CLUSTER personnel ( deptno NUMBER(2) ) ;Add the STAFF and DEPT tables to the cluster:,CREATE TABLE staff (staffno NUMBER PRIMARY KEY, staffname VARCHAR2(10) roomno NUMBER(2,3), deptno NUMBER(2) NOT NULL ) CLUSTER personnel (dept
11、no);,CREATE TABLE dept (deptno NUMBER(2), deptname VARCHAR2(9) CLUSTER personnel (deptno);,Cluster key,Intra file clustering,cluster around a clustering field in a single stored file e.g. frequently access STUDENT by yearcreate table student (studentno number(8) primary key, givenname char(20), surn
12、ame char(20), hons char(3), tutorid number(4), yearno number(1) not null, cluster year(yearno), );,4. Construct Access Structures for the join attributes,Access Structures / Access Paths Indexes Multi-level indexes B trees, B+ trees Hashing BitmapAccess Methods routines that allow operations to be a
13、pplied to a file,Primary Index,Data File,Index File,Data file is physically ordered on a key field (ordering key field),Oracle: Index-organized Tables,create table student (studentno number(8) primary key, givenname char(20), surname char(20), hons char(3), tutorid number(4), yearno number(1) not nu
14、ll, ORGANIZATION INDEX TABLESPACE students OVERFLOW TABLESPACE students_overflow;,Clustering Index,Data file is physically ordered on a non-key field (clustering field),Index File,Data File,Clustering Index in Oracle,The following statement creates a cluster index on the cluster key of PERSONNEL: CR
15、EATE INDEX idx_personnel ON CLUSTER personnel; After creating the cluster index, you can insert rows into either the STAFF or DEPT tables.,Clustering Index with Separate Blocks,Separate blocks for each group of records with the same cluster field value,Index File,Data File,Dense Secondary Index on a
16、 non-ordering key field,Index field value,Block pointer,Index File,Data File,Oracle: Create Index,create table enrol (studno number(8), courseno char(5), primary key (studno, courseno), );CREATE INDEX enrol-idx1 ON enrol (studno, courseno);CREATE INDEX enrol-idx2 ON enrol (courseno, studno);,Seconda
17、ry Index on a non-key field,Field value,Block pointer,Blocks of record pointers,Data File,Indexing field,Index File,Dense & Sparse Indexes,Dense Index Every record in the data file is in the index Sparse Index Not every record in the data file is in the index. The index indicates the block of record
18、s takes less space quicker to scan the index efficient but.no existence test based on the index A file can have one sparse index and many dense indexes, because a sparse index relies on a unique physical ordering of the data file on disk,Types of Keys,Unordered data files lots of secondary indexes S
19、pecify ordering attribute for file primary / clustering index attribute used most often for joins,Analysing database queries and transactions,Each queryfiles that will be accessedfields whose value is retrieved access pathsfields specified in selection conditions access pathsfields specified in join
20、s access paths Each update transactionfiles that will be updatedtype of update operation on each filefields used in selection conditionsfields whose value is modified avoid access structure,Analysing database queries and transactions,Expected frequency of invocation of queries and transactions expec
21、ted frequency of each field as a selection field or join field over all transactions expected frequency of retrieving and /or updating each recordAnalysing time constraints of queries and transactions stringent performance constraints influence access paths on selection fieldsAnalysing expected freq
22、uency of update operations volatile files reduce number of access paths,Types and Properties of Indexes,Index Summary,Speeds up retrieval but slows down inserts and updates Improve performance when relations are large queries extract 25% of all tuple in a relation a where clause is properly construc
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- INTERNALSCHEMADESIGN PERFORMANCEANDINDEXINGPPT
