Links
Home
Oracle DBA Forum
Frequent Oracle Errors
TNS:could not resolve the connect identifier specified
Backtrace message unwound by exceptions
invalid identifier
PL/SQL compilation error
internal error
missing expression
table or view does not exist
end-of-file on communication channel
TNS:listener unknown in connect descriptor
insufficient privileges
PL/SQL: numeric or value error string
TNS:protocol adapter error
ORACLE not available
target host or object does not exist
invalid number
unable to allocate string bytes of shared memory
resource busy and acquire with NOWAIT specified
error occurred at recursive SQL level string
ORACLE initialization or shutdown in progress
archiver error. Connect internal only, until freed
snapshot too old
unable to extend temp segment by string in tablespace
Credential retrieval failed
missing or invalid option
invalid username/password; logon denied
unable to create INITIAL extent for segment
out of process memory when trying to allocate string bytes
shared memory realm does not exist
cannot insert NULL
TNS:unable to connect to destination
remote database not found'>ora-02019
exception encountered: core dump
inconsistent datatypes
no data found
TNS:operation timed out
PL/SQL: could not find program
existing state of packages has been discarded
maximum number of processes exceeded
error signaled in parallel query server
ORACLE instance terminated. Disconnection forced
TNS:packet writer failure
see ORA-12699
missing right parenthesis
name is already used by an existing object
cannot identify/lock data file
invalid file operation
quoted string not properly terminated
Materialize hint

Materialize hint

2004-12-27       - By Jonathan Lewis
Reply:     1     2     3     4     5     6     7     8     9  


In reverse order, the "with " clause names
and defines a subquery before its use in
a query - a bit like a macro in C.

Unlike C macros though, the optimizer can
choose to write your subquery in-line and then
optimise the expanded statement, or create a
temporary table from the definition and use the
temporary table for the main query.

You can choose to use the 'with ' clause simply
to make a complex SQL statement tidier, knowing
that there should be no performance benefit in
creating a temporary table.

If you want to control the optimiser, then the
'materialize ' hint makes it create a temporary
table; the 'inline ' hint makes it perform 'macro-
substitution '.

As far as I know, neither hint is documented.

The 'with ' clause (known as subquery factoring)
is quite flexible - though not yet as flexible as
DB2 's which can cope with recursive definitions).
Here 's an example I wrote to answer a fun puzzle
that Daniel Morgan put out on cdo.server some
months ago.

with age_list as (
select rownum age
from all_objects
where rownum <= 36
),
product_check as (
select
age1.age as youngest,
age2.age as middle,
age3.age as oldest,
age1.age + age2.age +age3.age as summed
from
age_list age1,
age_list age2,
age_list age3
where
age2.age >= age1.age
and age3.age >= age2.age
and age1.age * age2.age * age3.age = (
select max(age) from age_list
)
),
summed_check as (
select
youngest, middle, oldest, summed
from
(
select
youngest, middle, oldest, summed,
count(*) over(partition by summed) ct
from product_check
)
where ct > 1
)
select
*
from summed_check
where
oldest > middle
;


Regards

Jonathan Lewis

http://www.jlcomp.demon.co.uk/faq/ind_faq.html
The Co-operative Oracle Users ' FAQ

http://www.jlcomp.demon.co.uk/seminar.html
Public Appearances - schedule updated Dec 23rd 2004






-- -- Original Message -- --
From: "Mladen Gogala " <gogala@(protected) >
To: "oracle-l " <oracle-l@(protected) >
Sent: Saturday, December 25, 2004 5:05 AM
Subject: Materialize hint


I recently ran accross a SQL by Jonathan that uses "materialize " hint.
As was unable to find the hint documented anywhere, and God knows I
tried before asking the question, I must ask the folowing two =20
questions:

1) What does "materialize " hint do and where is it documented?
I was unable to find it documented in either 10g documentation
or 9.2 documentation.
2) The same question for "with generator " clause.

This question is, of course, meant for Jonathan but I 'd appreciate
anybody else 's answer as well.



--
http://www.freelists.org/webpage/oracle-l