IN Formal parameter acts like a constant:
Ever since we created our first stored packaged function, we have had to suffer a continual trade-off between the encapsulation of business rules and optimal performance.
We have usually paid a performance penalty for good programming practices in one or more of the following ways: The last issue in the list has, however, been addressed for many releases of Oracle and we will see how in this article.
This feature is so important that I decided to write an article on it for oracle-developer. To do this, we will need a sample table and function.
We will start with the table, as follows. We now have a small table with 1, rows and its statistics. Using 1, rows will make it easy to understand numbers such as selectivity the percentage of rows satisfied by a predicate and cardinality the number of rows returned after applying a predicate once we start to query it.
Our function takes a single parameter but returns a constant value.
We will now query our sample table and use our function in an equality predicate below. We will explain the query using Autotrace and also trace the CBO using the event that some developers will be familiar with.
What is more interesting in this output is the information highlighted in red lines beginning "No default These state that there are no default statistics selectivity or cost defined for our function. We usually ensure that we have representative statistics on our tables and indexes.
We might also set statistics for our external tables and use dynamic sampling for global temporary tables. This can lead to some sub-optimal execution plans and we can demonstrate this quite simply below.
The quick function is a simple wrapper for the built-in MOD function. The slow function has a small sleep embedded in it to slow it down but also wraps the MOD function. Note the order of the predicates in both the query and the Predicate Information section of the execution plan.
In fact, without any suitable statistics for our functions, the CBO will not re-order any of our function-based predicates. With this in mind, we will now re-order our predicates and execute the new query, as follows. Of course, this example was deliberately biased to demonstrate the effects of predicate ordering.
This is combined with two little-known features of Oracle: In the following sections, we will look at both methods.
For more information, see the Further Reading section at the end of this article. We will look at each in turn below, starting with default selectivity. We saw evidence of this in our trace file earlier, when the optimiser looked for any defined defaults when costing our function-based predicate.
We can set these defaults as follows: As we can see, we associate statistics with our functions.
Once we do this, the association is a known "object" and can be viewed in the data dictionary described later. Using Autotrace, we will run some new queries to see the effects of the default selectivities.
We are now ready to explain some queries. The CBO now has some information to work with! Of course, the key test is to determine what happens when we combine predicates. Now that we have default selectivity statistics, we can repeat our slower query as follows.Our PL SQL certification training course lets you learn the PL SQL language for query of Oracle databases.
We provide the best online training classes to help you learn the database tools, query language, subprogram, syntax query, basic and advanced DML, scripting.
This is my SQL Server Stored Procedure which is below: CREATE PROCEDURE passenger_details AS BEGIN SELECT Full_Name, Age, Nationality, Category, . Hi all, Migrating Oracle forms applications to ADF the one of the biggest issue is what to do with you existing PL/SQL code.
As we all aware that ADF is JEE technology based and it cannot directly interact with PL/SQL as we used to do in Oracle forms application. When I run the following in an Oracle shell it works fine truncate table table_name But when I try to put it in a stored procedure CREATE OR REPLACE PROCEDURE test IS BEGIN truncate table.
Compiling PL/SQL in Oracle 10g and beyond Mike Ault. As we noted, starting in Oracle 10g, PL/SQL can be compiled to native code. The compiling, along with overall improvements in PL/SQL compilation can mean speeding up PL/SQL execution by .
I have problem with Oracle and JMS. I created PL/SQL routine to send XML text (from file or CLOB) to queue, but this routine do not compile. My code looks like (filling message omitted): cre.