1 Optimizing Your ColdFusion Applications for Oracle Justin Fidler, CNA, CPS, CCFD Chief Technology Officer Bantu, Inc. 8 May 2001.

Slides:



Advertisements
Similar presentations
Tuning Oracle SQL The Basics of Efficient SQLThe Basics of Efficient SQL Common Sense Indexing The Optimizer –Making SQL Efficient Finding Problem Queries.
Advertisements

Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
SQL Tuning Briefing Null is not equal to null but null is null.
Chapter 9. Performance Management Enterprise wide endeavor Research and ascertain all performance problems – not just DBMS Five factors influence DB performance.
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
© Bharati Vidyapeeths Institute of Computer Applications and Management, New Delhi © Bharati Vidyapeeths Institute of Computer Applications and.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Characteristic Functions. Want: YearCodeQ1AmtQ2AmtQ3AmtQ4Amt 2001e (from fin_data table in Sybase Sample Database) Have: Yearquartercodeamount.
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Finding the Performance Bottlenecks in Your Application Ian Jones and Roger Schrag Database Specialists, Inc. IOUG-A Live! 1999 Paper.
Copyright © 200\8 Quest Software High Performance PL/SQL Guy Harrison Chief Architect, Database Solutions.
Agenda Overview of the optimizer How SQL is executed Identifying statements that need tuning Explain Plan Modifying the plan.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 8 Advanced SQL.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Chapter 7 Advanced SQL Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
5 Creating the Physical Model. Designing the Physical Model Phase IV: Defining the physical model.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Concepts of Database Management Sixth Edition
ORACLE ONLINE TRAINING Contact our Support Team : SOFTNSOL India: Skype id : softnsoltrainings id:
Introduction to Databases Chapter 8: Improving Data Access.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 8 Advanced SQL.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Copyright © 2014 Pearson Education, Inc. 1 CHAPTER 7: ADVANCED SQL Essentials of Database Management Jeffrey A. Hoffer, Heikki Topi, V. Ramesh.
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
Chapter 7 Advanced SQL Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
DBSQL 14-1 Copyright © Genetic Computer School 2009 Chapter 14 Microsoft SQL Server.
Oracle9i Performance Tuning Chapter 1 Performance Tuning Overview.
Chapter 7 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi.
Module 11: Programming Across Multiple Servers. Overview Introducing Distributed Queries Setting Up a Linked Server Environment Working with Linked Servers.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Discovering Computers Fundamentals Fifth Edition Chapter 9 Database Management.
1 Copyright © 2004, Oracle. All rights reserved. Introduction.
Concepts of Database Management Seventh Edition
Views Lesson 7.
Improving Database Performance Derrick Rapley
SQL Performance and Optimization l SQL Overview l Performance Tuning Process l SQL-Tuning –EXPLAIN PLANs –Tuning Tools –Optimizing Table Scans –Optimizing.
Creating Databases for web applications [Complete presentations] More SQL Class time: discuss final projects. Do posting if you have not done it.
8 1 Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Chapter 6 Procedural Language SQL and Advanced SQL Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Oracle tuning: a tutorial Saikat Chakraborty. Introduction In this session we will try to learn how to write optimized SQL statements in Oracle 8i We.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Module 4 Database SQL Tuning Section 3 Application Performance.
Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
1 Copyright © 2005, Oracle. All rights reserved. Following a Tuning Methodology.
Chapter 8 Views and Indexes 第 8 章 视图与索引. 8.1 Virtual Views  Views:  “virtual relations”. Another class of SQL relations that do not exist physically.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata RDBMS Concepts.
Module 9: Using Advanced Techniques. Considerations for Querying Data Working with Data Types Cursors and Set-Based Queries Dynamic SQL Maintaining Query.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
There’s a particular style to it… Rob Hatton
 CONACT UC:  Magnific training   
3 Copyright © 2006, Oracle. All rights reserved. Designing and Developing for Performance.
Tuning Oracle SQL The Basics of Efficient SQL Common Sense Indexing
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Tuning Transact-SQL Queries
Query Optimization Techniques
Database Systems: Design, Implementation, and Management Tenth Edition
Database Performance Tuning and Query Optimization
CSCI 2141 – Intro to Database Systems
ISYS366, Database Administration II
Contents Preface I Introduction Lesson Objectives I-2
Chapter 8 Advanced SQL.
Chapter 11 Database Performance Tuning and Query Optimization
Database Systems: Design, Implementation, and Management Tenth Edition
SQL Server Query Design and Optimization Recommendations
Presentation transcript:

1 Optimizing Your ColdFusion Applications for Oracle Justin Fidler, CNA, CPS, CCFD Chief Technology Officer Bantu, Inc. 8 May 2001

2 Overview  Why Oracle?  Configuring Your Platform  Query Tuning  CFQUERYPARAM  Special Coding Techniques  NULL Handling  Lists of Values  Date Handling  BLOCKFACTOR  Further Reading, Questions

3 Why Oracle?  Industry-accepted platform  Runs on virtually any server platform  Large base of Oracle knowledge  Robust, scalable, proven technology  Widely supported  BUT.. It won’t be cheap!

4 Configuring Your Platform -- Database  Oracle 8i is the current popular version  Standard vs. Enterprise Edition  Beware of “App Server” focus  Have a DBA to help with configuration  Use an internal-address NIC (security)  Don’t skimp on hardware -- typically single point of failure  Perform routine maintenance (tablespace sizing, init settings, backups, table index analysis)

5 Configuring Your Platform -- ColdFusion  Only the Enterprise Edition provides native Oracle drivers  Use and enable connection pooling  Set connection pooling similar to simultaneous request limit, in most cases  Beware of running out of connections -- have a DBA look at settings  Use a separate NIC for the database traffic

6 Query Tuning  Most poor database performance results from poorly- designed queries  EXPLAIN PLAN will solve most of your problems  Use TKPROF in severe cases  Have your DBA closely check and monitor Oracle performance statistics

7 Query Tuning - EXPLAIN PLAN Bad Query: SELECT u.gender FROM users u, user_chat_preferences ucp WHERE ucp.user_id = u.user_id AND u.logon_id='justin’ Output: SELECT STATEMENT Cost= 4806 NESTED LOOPS TABLE ACCESS FULL USERS TABLE ACCESS FULL USER_CHAT_PREFERENCES

8 Query Tuning - EXPLAIN PLAN Good Query: SELECT u.gender FROM users u, user_chat_preferences ucp WHERE ucp.user_id = u.user_id AND u.logon_id='justin’ Output: SELECT STATEMENT Cost= 4 NESTED LOOPS TABLE ACCESS BY INDEX ROWID USERS INDEX UNIQUE SCAN UK_USERS_LOGON_ID INDEX UNIQUE SCAN PK_USER_CHAT_PREFERENCES

9 CFQUERYPARAM  Introduced in CF4.5  Enormous performance improvement  Works with any database that supports “bind” variables  Oracle SQL statement cache is literal and case- sensitive  Statement cache determines execution plans

10 CFQUERYPARAM Before Example Your Code before CFQUERYPARAM: SELECT username FROM users WHERE user_id=#SESSION.USER_ID# In the Database before CFQUERYPARAM: SELECT username FROM users WHERE user_id=2236

11 CFQUERYPARAM After Example Your Code after CFQUERYPARAM: SELECT username FROM users WHERE user_id= In the Database after CFQUERYPARAM: SELECT username FROM users WHERE user_id=:1

12 CFQUERYPARAM Summary  Works with all datatypes except BLOBS, including dates, characters, numbers  Null handling is done with the NULL=“YES” parameter  Can be used on UPDATEs, INSERTs, SELECTs, DELETEs  Should be used for all literal and dynamic values (parameterized values)  Bind variable enumeration will appear in debug output  No reason not to use CFQUERYPARAM

13 Special Coding Techniques  SELECTs should use listed field names instead of “SELECT *”  SELECTs should only select the fields needed for the query  INSERT statements should list field names explicitly: INSERT INTO tablename(field1,field2,…) VALUES (value1,value2,…)  Explicit field listing helps with different database field ordering (production vs. development)

14 More Coding Techniques  SIMPLE computations can be done in the query: SELECT product_id, price*1.05 as taxprice FROM products WHERE category_id=6  Complex operations should be avoided  Correlated Subqueries  GROUP BY, HAVING, UNION (temp sort area)  Many table complex joins  Aggregate functions, whenever possible  Stored Procedures, when applicable

15 NULL Handling  Evaluation of NULLs can often be misleading (IS NULL vs. = NULL, GTE evaluations)  NULLs can’t be indexed  Aggregate queries like MAX and MIN may return NULL  Try to design your data model so that NULLs aren’t allowed  Use other identifiers for NULL  Start with no columns nullable, then make a case for each to allow NULLs

16 NULL with NVL Use in a general query: SELECT product_id, NVL(price,-1) as NULLprice FROM products WHERE category_id=6 Use in an aggregate function (note placement of NVL): SELECT NVL(MAX(price),0) as maxprice FROM products WHERE category_id=6

17 Lists of Values  Improved performance over a join, if you can enumerate the items in code SELECT DECODE(gender,'M','Male','F','Female','N','Unknown') as fullgender FROM users

18 Date Handling  Do not assume CF will handle date conversion  Non-literal date conversion depends on server locale settings  Oracle in-line date conversion functions are very fast  Bind variables are supported (use character type)  Multi-lingual conversion is supported

19 Date Handling Examples SELECT event_id FROM calendar WHERE start_date > TO_DATE('#DateFormat(l_In_Date,"MMDDYYYY")#','MMDDYYYY') SELECT TO_CHAR(sale_date, 'Day DD Month YYYY HH24:MI:SS') as nice_sale_date FROM sales WHERE sales_id=3939 Nice_sale_date Wednesday 25 October :16:13

20 More Date Handling Examples In French: SELECT TO_CHAR(sale_date,'Day DD Month YYYY HH24:MI:SS','NLS_DATE_LANGUAGE= FRENCH') as nice_sale_date FROM sales WHERE sales_id=3939 Nice_sale_date Mercredi 25 Octobre :16:13

21 BLOCKFACTOR  Directive for database fetch size  Only applies to SELECT statements SELECT product_id, product_name FROM products

22 Further Reading  Oracle Technet --  Allaire Developer Exchange  Oracle MetaLink (part of Oracle Support)  Many good Oracle books (O’Reilly, Oracle Press) Questions?