JDeveloper ADF and the Oracle database – friends not foes SAGE Computing Services Customised.

Slides:



Advertisements
Similar presentations
Phoenix We put the SQL back in NoSQL James Taylor Demos:
Advertisements

12 Copyright © 2005, Oracle. All rights reserved. Query Rewrite.
PHP II Interacting with Database Data. The whole idea of a database-driven website is to enable the content of the site to reside in a database, and to.
Why is that LOV in the screen not returning me desired value?
Introduction to SQL Tuning Brown Bag Three essential concepts.
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.
PL/SQL.
WaveMaker Visual AJAX Studio 4.0 Training
AN INTRODUCTION TO PL/SQL Mehdi Azarmi 1. Introduction PL/SQL is Oracle's procedural language extension to SQL, the non-procedural relational database.
Keys, Referential Integrity and PHP One to Many on the Web.
Technical BI Project Lifecycle
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Agenda Overview of the optimizer How SQL is executed Identifying statements that need tuning Explain Plan Modifying the plan.
Introduction to Structured Query Language (SQL)
David Konopnicki Choosing Access Path ä The basic methods. ä The access paths and when they are available. ä How the optimizer chooses among the.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
Introduction to Structured Query Language (SQL)
Access Path Selection in a Relation Database Management System (summarized in section 2)
Copying, Managing, and Transforming Data With DTS.
Denny Cherry twitter.com/mrdenny.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
1 INTRO TO BUSINESS COMPONENTS FOR JAVA (BC4J) Matt Fierst Computer Resource Team OracleWorld Session
Module 3: Table Selection
Bordoloi and Bock CURSORS. Bordoloi and Bock CURSOR MANIPULATION To process an SQL statement, ORACLE needs to create an area of memory known as the context.
Server-side Scripting Powering the webs favourite services.
What is Sure BDCs? BDC stands for Batch Data Communication and is also known as Batch Input. It is a technique for mass input of data into SAP by simulating.
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
PHP meets MySQL.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Module 5 Planning for SQL Server® 2008 R2 Indexing.
Database Systems Microsoft Access Practical #1 Creating Tables Nos 215.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
M1G Introduction to Database Development 5. Doing more with queries.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
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.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
O FFICE M ANAGEMENT T OOL - II B BA -V I TH. Abdus Salam2 Week-7 Introduction to Query Introduction to Query Querying from Multiple Tables Querying from.
Advanced SQL: Triggers & Assertions
Module 4 Database SQL Tuning Section 3 Application Performance.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
1 Guide to Oracle10G CHAPTER 7: Creating Database Reports 7.
© IBM Corporation 2005 Informix User Forum 2005 John F. Miller III Explaining SQLEXPLAIN ®
LANDESK SOFTWARE CONFIDENTIAL Tips and Tricks with Filters Jenny Lardh.
Microsoft FrontPage 2003 Illustrated Complete Integrating a Database with a Web Site.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
SQL SERVER DAYS 2011 Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
Session 1 Module 1: Introduction to Data Integrity
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
 CONACT UC:  Magnific training   
ADVANCED SQL.  The SQL ORDER BY Keyword  The ORDER BY keyword is used to sort the result-set by one or more columns.  The ORDER BY keyword sorts the.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
Views / Session 3/ 1 of 40 Session 3 Module 5: Implementing Views Module 6: Managing Views.
Oracle 11g: SQL Chapter 5 Data Manipulation and Transaction Control.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
SQL Server Statistics and its relationship with Query Optimizer
ATS Application Programming: Java Programming
From 4 Minutes to 8 Seconds in an Hour (or a bit less)
ISC440: Web Programming 2 Server-side Scripting PHP 3
Chapter 8 Advanced SQL.
Presentation transcript:

JDeveloper ADF and the Oracle database – friends not foes SAGE Computing Services Customised Oracle Training Workshops and Consulting Penny Cookson (Building applications using JDeveloper ADF without killing database performance)

SAGE Computing Services Customised Oracle Training Workshops and Consulting Penny Cookson Managing Director and Principal Consultant Working with since 1987 Oracle Magazine Educator of the Year 2004

Agenda View Objects and the WHERE clause How to find out what’s happening in the database View criteria View Objects Tuning Options Using functions View Accessors Skewed data Adding Hints Managing database connections Application Module Pooling

“ADF Business Components stands out for the task of business service development and object relational mapping by virtue of its highly declarative metadata based development style.” Planning Stage

The database is just a persistent data store, we don’t need to worry about it Development Stage

This new web application is really slow Production Stage

What have you done to MY database Production Stage

S So how do you protect your database from the Java people?

Its all about education

Database Centric – Model Layer Events Organisations Bookings Organisations VO Bookings VO Events VO SELECT Organisations EO Bookings EO Events EO INSERT UPDATE DELETE LOCK INSERT UPDATE DELETE LOCK INSERT UPDATE DELETE LOCK BookingService (Application Module ) COMMIT ROLLBACK

We are letting JDeveloper generate our SELECT statements Events Organisations Bookings Organisations VO Bookings VO Events VO SELECT Organisations EO Bookings EO Events EO INSERT UPDATE DELETE LOCK INSERT UPDATE DELETE LOCK INSERT UPDATE DELETE LOCK BookingService (Application Module ) COMMIT ROLLBACK

SELECT …….WHERE col = ‘bbbbb’ Full table scan Index scan aaaaa bbbbb ccccc ddddd eeeee aaaaa ggggg ccccc ddddd eeeee aaaaa kkkkk ccccc ddddd eeeee aaaaa bbbbb ccccc ddddd eeeee a z bbbb rowid aaaaa bbbbb ccccc ddddd eeeee aaaaa ggggg ccccc ddddd eeeee aaaaa kkkkk ccccc ddddd eeeee aaaaa bbbbb ccccc ddddd eeeee DB

Optimizer estimates cost of each possible access path and picks the cheapest DB

Determining the View Object query Jdev Bind variables View Criteria Custom sql (Expert mode)

An example - View Object with a Bind Variable Jdev

An example - View Object with a Bind Variable

That’s seems OK But what did it do in the database Jdev An example - View Object with a Bind Variable

View Objects – Finding the SQL There’s a row in here for each optimisation of a sql statement (until it gets aged out) It has been executed once With 135 blocks read per execution DB

View Objects – Finding the SQL DB

View Objects – Finding the SQL Plan Paste the sql_id in here DB

Why bother with all that database stuff when Jdev gives me an Explain Plan Jdev

Is that what it will really do?

Jdev

Doesn’t peek at bind variables Optimiser statistics need to be the same as production System statistics need to be the same as production Environment needs to be same as production Jdev Explain Plan Find out what its really doing

VO Tuning Options affect the statements executed Jdev

VO Tuning options This statement gets executed when the VO tuning options are set to: Rows in batches as needed DB

Jdev Managing Optional Parameters Required parameter works fine, but returns no rows if the parameter is null

Make the Bind variable Required = No Jdev

Bind Variable Oracle Documentation Required Select if you want to make the value of a name bind variable required for any usage the references the named bind variable. For example, when the value is required (default), all view criteria items that reference the named bind variable will fail to execute unless a valid value is supplied at runtime. Alternatively, you can leave the value not required and use the Create View Criteria dialog to specify whether or not individual view criteria items require the value

Recommendations So Far Forget about Explain plan – find out what its really done Required Bind variable is fine if you always provide a value for an indexed column

Using View Criteria View Criteria – Optional View Criteria – Ignore Null Values = Y Jdev

Using View criteria Execute with no parameter value All the rows returned Jdev

Bind Parameter – Required = Y View Criteria – Optional View Criteria – Ignore Null Values = Y No parameter value This is the statement that returns the rows DB

Bind Parameter – Required = Y View Criteria – Optional View Criteria – Ignore Null Values = Y No parameter value Read the entire table DB

I am sure it will be fine if I give it a parameter value Bind Parameter – Required = Y View Criteria – Optional View Criteria – Ignore Null Values = Y Parameter value was 1200 DB

Bind Parameter – Required = Y View Criteria – Optional View Criteria – Ignore Null Values = Y With parameter value DB

Bind Parameter – Required = N View Criteria – Optional View Criteria – Ignore Null Values = Y Required = N Jdev

Bind Parameter – Required = N View Criteria – Optional View Criteria – Ignore Null Values = Y View Criteria – Optional View Criteria – Ignore Null Values = Y Jdev

Bind Parameter – Required = N View Criteria – Optional View Criteria – Ignore Null Values = Y No parameter value supplied All the rows returned Jdev

Bind Parameter – Required = N View Criteria – Optional View Criteria – Ignore Null Values = Y DB Predicate for pBookingNo not included if bind variable is null

Bind Parameter – Required = N View Criteria – Optional View Criteria – Ignore Null Values = Y DB Bind variable has a value of 1206

Bind Parameters – Required = N Multiple View Criteria – Optional Multiple View Criteria – Ignore Null Values = Y Jdev

Bind Parameters – Required = N Multiple View Criteria – Optional Multiple View Criteria – Ignore Null Values = Y Jdev

Bind Parameters – Required = N Multiple View Criteria – Optional Multiple View Criteria – Ignore Null Values = Y Jdev

Bind Parameters – Required = N Multiple View Criteria – Optional Multiple View Criteria – Ignore Null Values = Y Includes the where clause if we have supplied a parameter value DB

Bind Parameters – Required = N Multiple View Criteria – Optional Multiple View Criteria – Ignore Null Values = Y Which allows it to choose the best index DB

Recommendations So Far Forget about Explain plan – find out what it really did Required Bind variable is fine if you always provide a value for an indexed column For flexibility and performance use multiple View Criteria with Parameter Required = N View Criteria – Optional View Criteria – Ignore Null Values = Y

Using Functions in the SELECT Jdev

Using Functions in the SELECT Didn’t someone say it was bad to do this? Jdev

View Object Tuning Options But it doesn’t matter - I am only getting 20 rows Jdev

Using Functions in the SELECT DB

Sort the Rows (either User Sort or in the VO) Jdev

Sort the Rows (either User Sort or in the VO) You might be getting only getting 20 rows back to the middle tier – but the database has to read all of them DB

View Object – Multiple Entities + Transient Attribute Jdev

View Object – Multiple Entity Objects Jdev

View Object – Multiple Entity Objects - Sort Jdev

View Object – Multiple Entity Objects than this This is much better DB

View Object – Multiple Entity Objects But why does it have to keep selecting from EVENTS DB

View Object – Multiple Entity Objects Jdev

View Object – Multiple Entity Objects Now its all selected from the join DB So – if you include a derived attribute from another EO also include the source attributes

View Object – Fetching multiple values from the same tables SELECT taxFileNo, getTaxCalc1(taxFileNo), getTaxCalc2(taxFileNo); getTaxCalc3(taxFileNo), getTaxCalc4(taxFileNo) FROM TaxDetailsTable All these functions get the same rows from the tables, they just return different columns Jdev

View Object – Fetching multiple values from the same tables SELECT taxFileNo, getTaxCalcs(taxFileNo), FROM TaxDetailsTable value1 value1|value2|value3|value4 value2value3value4 Define transient attributes in the VO Jdev

View Object – Tuning Options It defines how many rows are returned to the middle tier NOT how many are read from the database Jdev

Recommendations So Far Forget about Explain plan – find out what it really did Required Bind variable is fine if you always provide a value for an indexed column For flexibility and performance use multiple View Criteria with Parameter Required = N View Criteria – Optional View Criteria – Ignore Null Values = Y For derived values, don’t use functions unless you have to Select all the sources of a derived attribute If you have to use functions fetch everything you need in one operation

Modified columns in the WHERE clause Modified columns don’t use an index on the column DB Columns that are modified by expressions or functions are unable to use an index unless a function based index has been created Examples: WHERE upper(name) = ‘VALUE’ WHEREsal * 1.1 = 2000 WHEREto_char(start_date,’dd/mm/yy’) = ‘01/03/93’

View Object – Case Sensitive View Criteria Jdev

View Object – Case Sensitive View Criteria Create a function based index DB

Validation – IN View Accessor Jdev

Validation – IN View Accessor Jdev

Validation – IN View Accessor Jdev Validating this reads 100,438 blocks in a full scan of EVENTS_LARGE (and takes a very long time)

Validation – KEY EXISTS in View Accessor Jdev

Validation – KEY EXISTS in View Accessor Jdev Validating this reads 99 blocks in a Unique Index scan of EVENTS_LARGE (and is really quick)

Displaying Additional Data – View Accessor Jdev

Displaying Additional Data – View Accessor

Jdev Displaying Additional Data – View Accessor

Jdev Displaying Additional Data – View Accessor

Jdev Displaying this needs a full scan of ORGANISATIONS Displaying Additional Data – View Accessor

Displaying Additional Data - Multiple Entity Usages Jdev

Displaying Additional Data - Multiple Entity Usages Jdev

Displaying Additional Data - Multiple Entity Usages Jdev Displaying this fetches Organisations.name from a join in the VO query

Recommendations So Far Forget about Explain plan – find out what it really did Required Bind variable is fine if you always provide a value for an indexed column For flexibility and performance use multiple View Criteria with Parameter Required = N View Criteria – Optional View Criteria – Ignore Null Values = Y For derived values, don’t use functions unless you have to Select all the sources of a derived attribute If you have to use functions fetch everything you need in one operation Don’t use Ignore Case unless you have a function based index Be wary of using View Accessors for large data sets

Skewed Data Majority value Minority value DB

Skewed Data in SQL If I execute the statement with a minority value then a majority (twice) it reassesses the plan and makes a different decision DB

Skewed Data in ADF Query for the minority case Jdev

Skewed Data in ADF DB

Skewed Data in ADF Query for the majority case Jdev

View Object – Skewed Data in ADF Even after 4 executions its still using the same plan DB

View Object – Execute in a different session Open the same page in a different window DB

View Object – BIND_AWARE Add this hint to all Vos on skewed data (with histograms) Jdev

Recommendations So Far Forget about Explain plan Required Bind variable is fine if you always provide a value for an indexed column For flexibility and performance use multiple View Criteria with Parameter Required = N View Criteria – Optional View Criteria – Ignore Null Values = Y For derived values, don’t use functions unless you have to Select all the sources of the derived attribute If you have to use functions fetch everything you need in one operation Be wary of using View Accessors for large data sets Don’t use Ignore Case unless you have a function based index Use BIND_AWARE hint for skewed data

So what about all the cute new query components

Jdev

xxxxxxxxxx

This is fine because the user picked an indexed attribute to query

xxxxxxxxxx

This has to full scan because the attribute the user queried was not indexed

xxxxxxxxxx

Running PL/SQL from Java LIKE ‘%something%’ can’t use an index even if there is one

xxxxxxxxxx

Write our own searches with a known set of parameters Don’t allow users to sort large sets of records

Connections - Logging Jdev

Connections - Logging Jdev

Connections - Logging Jdev

Connections - Logging Jdev

Connections Jdev

Using BTFs in Regions Jdev AppModule Connection defined as: java:comp/env/jdbc/conf2011DS

Using BTFs in Regions Jdev

Using BTFs in Regions Jdev

Database sessions in use DB

Using BTFs in Regions Jdev

Database sessions in use DB

Using BTFs in Regions AppModule Connection defined as: java:comp/env/jdbc/EventsServiceConnDS Jdev

Using BTFs in Regions Jdev

Database sessions in use DB

Using BTFs in Regions Jdev

Using BTFs in Regions Jdev

Database sessions in use DB

Use the same connection

Passivation Settings Jdev

Passivation Settings

Recommended for Development / Testing

Passivation Settings alter system flush shared_pool Execute With Params twice more 8 executions

Recommended for Development / Testing You need to run like this for development / testing But turn it back on for UAT

Recommendations  Forget about Explain plan  Required Bind variable is fine if you always provide a value for an indexed column  For flexibility and performance use multiple View Criteria with Parameter Required = N View Criteria – Optional View Criteria – Ignore Null Values = Y  For derived values, don’t use functions unless you have to  Select all the sources of the derived attribute  If you have to use functions fetch everything you need in one operation  Don’t use Ignore Case unless you have a function based index  Be wary of using View Accessors for large data sets  Use BIND_AWARE hint for skewed data  Use the same connection  Bundle PL/SQL calls  Use Application Module pooling in UAT

JDeveloper ADF and the Oracle database – friends not foes SAGE Computing Services Customised Oracle Training Workshops and Consulting Penny Cookson Questions