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 B0000001G. Sullivan B0000002T. Trappenberg B0000003S. Marche B0000004A. Uteck Banner IDCourse B0000001ECMM6000 B0000002ECMM6010 B0000003ECMM6020 B0000004ECMM6030

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 1B001Chris2023232 2B005Bates2123232 3B003Hugh2923902 4B010Mark2823902 5B008Martin3323920 6B002Jones2232902 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_C003983 (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_C003983 (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 2001. 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 – http://metalink.oracle.comhttp://metalink.oracle.com Oracle Performance Tuning - Richard J.Niemiec, - Oracle Press Database Design Fundamentals – Naphtali Rishe,1988 – Prentice Hall Oracle Market share http://www.oracle.com/ip/index.html?database1.html http://www.oracle.com/ip/index.html?database1.html Unbreakable system http://www.oracle.com/oramag/oracle/02- mar/index.html?o22break.html http://www.oracle.com/oramag/oracle/02- mar/index.html?o22break.html Microsoft LongHorn http://msdn.microsoft.com/Longhorn/understand ing/pillars/WinFS/default.aspx


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

Similar presentations


Ads by Google