Database Tuning in 5 Agenda Why tune databases Scope for tuning Parameters Design Monitor and Analyze Trivia
Database Tuning in 6 Why is it so critical? Web Server Database The Database lies at the root of an e-commerce application !
Database Tuning in 7 Scope for Tuning System level Operating System, Hardware Database level Temporary space, Rollback segments Application level Query Tuning, Design
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)
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
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
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
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
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)
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
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 !
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)
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
Your consent to our cookies if you continue to use this website.