I enjoyed the answers and questions about hidden features in sql server
What can you tell us about Oracle?
Hidden tables, inner workings of ..., secret stored procs, package that has good utils...
I enjoyed the answers and questions about hidden features in sql server
What can you tell us about Oracle?
Hidden tables, inner workings of ..., secret stored procs, package that has good utils...
"Full table scans are not always bad. Indexes are not always good."
An index-based access method is less efficient at reading rows than a full scan when you measure it in terms of rows accessed per unit of work (typically per logical read). However many tools will interpret a full table scan as a sign of inefficiency.
Take an example where you are reading a few hundred invoices frmo an invoice table and looking up a payment method in a small lookup table. Using an index to probe the lookup table for every invoice probably means three or four logical io's per invoice. However, a full scan of the lookup table in preparation for a hash join from the invoice data would probably require only a couple of logical reads, and the hash join itself would cmoplete in memory at almost no cost at all.
However many tools would look at this and see "full table scan", and tell you to try to use an index. If you do so then you may have just de-tuned your code.
Incidentally over reliance on indexes, as in the above example, causes the "Buffer Cache Hit Ratio" to rise. This is why the BCHR is mostly nonsense as a predictor of system efficiency.
The cardinality hint is mostly undocumented.
I don't know if this counts as hidden, but I was pretty happy when I saw this way of quickly seeing what happened with a SQL statement you are tuning.
Where:
Where the estimated plan varies from the actual execution by orders of magnitude, you know you have problems.
WITH Clause
Since Apex is now part of every Oracle database, these Apex utility functions are useful even if you aren't using Apex:
Scalar subquery caching is one of the most surprising features in Oracle
The "caching" subquery above evaluates
my_function(t.x)
only once per unique value oft.x
. If you have large partitions of the samet.x
value, this will immensely speed up your queries, even ifmy_function
is not declaredDETERMINISTIC
. Even if it wasDETERMINISTIC
, you can safe yourself a possibly expensive SQL -> PL/SQL context switch.Of course, if
my_function
is not a deterministic function, then this can lead to wrong results, so be careful!