Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Tuning in - Philip K. Kuruvilla. Database Tuning in 2 Login.

Similar presentations


Presentation on theme: "Database Tuning in - Philip K. Kuruvilla. Database Tuning in 2 Login."— Presentation transcript:

1 Database Tuning in - Philip K. Kuruvilla

2 Database Tuning in 2 Login

3 Database Tuning in 3 The World Wide Wait

4 Database Tuning in 4 Looks Familiar ?

5 Database Tuning in 5 Agenda Why tune databases Scope for tuning Parameters Design Monitor and Analyze Trivia

6 Database Tuning in 6 Why is it so critical? Web Server Database The Database lies at the root of an e-commerce application !

7 Database Tuning in 7 Scope for Tuning System level Operating System, Hardware Database level Temporary space, Rollback segments Application level Query Tuning, Design

8 Database Tuning in 8 Tuning Parameters Throughput and Response Time Throughput: Ratio of total data read to total time spent in servicing the request Response Time: Difference between time at which a request is completed and response is received Type of Application OLTP (requires better throughput) Batch processing (requires shorter response time)

9 Database Tuning in 9 Design Normalization Not always a good idea to Normalize Better to have a single table here Banner IDProfessor B G. Sullivan B T. Trappenberg B S. Marche B A. Uteck Banner IDCourse B ECMM6000 B ECMM6010 B ECMM6020 B ECMM6030

10 Database Tuning in 10 Application Design Simple and efficient queries Minimise the number of query blocks SELECT * FROM ALL_STUDENTS A WHERE A.NAME IN (SELECT GS.NAME FROM GRAD_STUDENTS GS) SELECT * FROM ALL_STUDENTS A, GRAD_STUDENTS GS WHERE A.NAME = GS.NAME = Return efficient batch sizes Use Stored Procedures/ Functions/ Triggers Startup costs are high. Running costs are low

11 Database Tuning in 11 Indexes What are they? Defined on a column Avoid full table scans How do they work When do they NOT work ! Trade off between insert/update and select Primary keys are automatically indexed rowID (hidden ) Banner ID NameAgeTel 1B001Chris B005Bates B003Hugh B010Mark B008Martin B002Jones Banner IDRow ID B0011 B0026 B0033 B0052 B0085 B0104

12 Database Tuning in 12 Monitoring Plan table Shows how an SQL query is executed Shows use of indexes, effect of Optimizers Gives a cost factor for a query

13 Database Tuning in 13 Explain Plan table LNAME FNAME CUST_ID CUSTOMER TOTAL CUST_ID ORDER_ID PRODUCT_OR DER QTY PRODUCT ID ORDER_ID ORDER_DETA IL Indexed Column Non Indexed Column SELECT POD.PROD_ID, POD.QTY FROM CUSTOMER C, PRODUCT_ORDER PO, PRODUCT_ORDER_DETAIL POD WHERE C.CUST_ID = 2 AND PO.CUST_ID = C.CUST_ID AND PO.ORDER_ID = POD.ORDER_ID SELECT POD.PROD_ID, POD.QTY FROM CUSTOMER C, PRODUCT_ORDER PO, PRODUCT_ORDER_DETAIL POD WHERE PO.CUST_ID = 2 AND PO.CUST_ID = C.CUST_ID AND PO.ORDER_ID = POD.ORDER_ID SELECT POD.PROD_ID, POD.QTY FROM PRODUCT_ORDER PO, ORDER_DETAIL POD WHERE PO.CUST_ID = 2 AND PO.ORDER_ID = POD.ORDER_ID SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=51) NESTED LOOPS (Cost=3 Card=1 Bytes=51) NESTED LOOPS (Cost=2 Card=1 Bytes=39) INDEX (UNIQUE SCAN) OF SYS_C (UNIQUE) TABLE ACCESS (FULL) OF PRODUCT_ORDER (Cost=1 Card=1 Bytes=13) TABLE ACCESS (FULL) OF PRODUCT_ORDER_DETAIL (Cost=1 Card=7 Bytes=84) SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=38) NESTED LOOPS (Cost=3 Card=1 Bytes=38) NESTED LOOPS (Cost=2 Card=1 Bytes=26) INDEX (UNIQUE SCAN) OF SYS_C (UNIQUE) TABLE ACCESS (FULL) OF PRODUCT_ORDER (Cost=1 Card=1 Bytes=13) TABLE ACCESS (FULL) OF PRODUCT_ORDER_DETAIL (Cost=1 Card=7 Bytes=84) SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=25) NESTED LOOPS (Cost=2 Card=1 Bytes=25) TABLE ACCESS (FULL) OF PRODUCT_ORDER ( Cost=1 Card=1 Bytes=13) TABLE ACCESS (FULL) OF PRODUCT_ORDER_DETAIL (Cost=1 Card=7 Bytes=84)

14 Database Tuning in 14 Advanced Trace functionality Real time data Can identify deadlocks, excessive waits Optimizers within Oracle Rule Based Optimizer (RBO) Uses Pre–determined rules Independent of data Cost Based Optimizer (CBO) Optimizes based on table/ index information gathered Requires that database is analyzed frequently Default in Oracle

15 Database Tuning in 15 Summary Tuning is a series of trade offs Always better to tune during the design phase than after implementation Sometimes its plain common sense !

16 Database Tuning in 16 Trivia Oracle has been the leading database manufacturer for the last 5 years. (source: IDC, 2003) Oracle: 39.4%, DB2: 33.6%, SQL Server: 11.1% Broad coverage of OS (Windows, Unix & Linux) Unbreakable Campaign Advertising campaign in Late Declared that Oracle 9i was unbreakable Open challenge to hackers Windows Long Horn. Will feature a new File system WinFS which will store files using database technologies (source: Microsoft)

17 Database Tuning in 17 References Metalink – Oracle Performance Tuning - Richard J.Niemiec, - Oracle Press Database Design Fundamentals – Naphtali Rishe,1988 – Prentice Hall Oracle Market share Unbreakable system mar/index.html?o22break.html mar/index.html?o22break.html Microsoft LongHorn ing/pillars/WinFS/default.aspx


Download ppt "Database Tuning in - Philip K. Kuruvilla. Database Tuning in 2 Login."

Similar presentations


Ads by Google