Oracle Scratchpad

December 31, 2010

Quiz Night

Filed under: Infrastructure — Jonathan Lewis @ 11:45 pm UTC Dec 31,2010

Many people in the UK like to greet the new year with some sort of party, and in this household the type of party we like includes old-fashioned party games (can you draw “Brief Encounters” in 10 seconds ?); so, for all those members of the Oracle community who haven’t prepared their party games this year, here’s a little quiz:

Which processes could report waits for “log file sequential read”, and why are they reading log files ?
(more…)

December 29, 2010

Existence

Filed under: CBO,Execution plans — Jonathan Lewis @ 11:14 pm UTC Dec 29,2010

Here’s a posting on OTN that demonstrates a piece of SQL that uses inline scalar subqueries which are all “existence” tests to produce (presumably) a set of flags describing the state of a particular item of data.

I’ve linked to it because I contributed a comment about the implications of the cost figures that appeared in the execution plan for two of the “exists” subqueries. Essentially “existence” is optimized as a “first_rows(1)” operation – which results in two lines of the plan showing two different costs for table scans of the same table.
(more…)

December 27, 2010

Index Rebuilds

Filed under: Index Rebuilds,Indexing — Jonathan Lewis @ 9:36 am UTC Dec 27,2010

There are many suggestions floating around the internet about identifying which Oracle indexes to rebuild. One of these involves running the validate (or analyze index validate) command on an index and checking the resulting figures in view index_stats to determine whether or not del_lf_rows exceeds some percentage (usually 20%) of lf_rows and rebuilding the index if so. Since this suggestion came up, yet again, in a recent OTN thread about Oracle index rebuilding I thought I’d write up a quick note highlighting one of the obvious flaws in the argument.

I’m not going to bother pointing out the threat inherent in the table-locking when you use the “validate index” command (or the “analyze index validate” equivalent) but I think it’s worth making some comments about the misunderstanding built into this policy. So let’s start by building some data, creating an index on it, then deleting 90% of the data:
(more…)

December 23, 2010

Private Redo

Filed under: redo,undo — Jonathan Lewis @ 10:17 am UTC Dec 23,2010

About this time last year I wrote a short answer on OTN about Private Redo Threads and In-Memory Undo. Thanks to a follow-up question a year later I’ve been prompted to supply a link to my original answer because it was actually pretty good: OTN Thread “In Memory Undo”.

Update: If you’re looking at this note and haven’t expanded the view to see the comments, make sure that you do look at them since they include a couple of technical details I described in response to follow-up questions.

December 21, 2010

Staying fresh

Filed under: Infrastructure,Oracle — Jonathan Lewis @ 9:33 pm UTC Dec 21,2010

I often spend a few minutes on “random browsing” on the internet, keeping an eye open for new ideas; and it’s interesting how often I find new technology being applied to an old requirement. Here’s one I found recently:

    How do you recover a user that’s been dropped by accident?

If you’re using “database flashback” technology then you have an option to make it a lot simpler than it used to be.

December 20, 2010

Index join – 4

Filed under: CBO,Execution plans,Index Joins,Indexing,Tuning — Jonathan Lewis @ 6:19 pm UTC Dec 20,2010

In a recent note I wrote about index joins I made a passing comment about limitations in the optimizer’s available strategies that might make you choose to write your code to emulate an index join through explicit SQL references.

Here are two SQL similar SQL statements (with execution plans) that demonstrate the initial problem – the first is just a restatement of the basic example I supplied in the first article:
(more…)

December 17, 2010

System Statistics

Filed under: Infrastructure,Oracle,Statistics,System Stats — Jonathan Lewis @ 6:10 pm UTC Dec 17,2010

I wrote an article about system statistics / CPU Costing for Oracle magazine a few years ago – and last week I realised that I’ve never supplied a link to it in the notes and comments I’ve made about system statistics. So I’ve just run a search through the Oracle website trying to find it – and discovered that it’s no longer available. Apparently the editors have decided that any technical articles over a certain age should be withdrawn in case they are out of date and misleading. (Clearly they’ve read my blog on trust – I wish the people maintaining Metalink would do the same as the magazine editors – but they probably have a much larger volume to worry about).

However, I have discovered translations of the article in Russian, Korean and Chinese – so if you can read any of these languages, you might want to take a look at them before they disappear too.

If you want an original English version – dated April 2004, which is when I sent it in to Oracle Magazine, and before it underwent some editing – I’ve posted it as a pdf file.

[More on System Statistics]

December 16, 2010

FBI oddities

Filed under: Function based indexes,Indexing — Jonathan Lewis @ 6:15 pm UTC Dec 16,2010

Function-based indexes are wonderful things – but they don’t always work exactly as expected. Here’s an example of one such anomaly.

Imagine you have some type of “orders” table where most orders are in a “finished with” state, and you have a requirement to access the small number of orders in the “new” state. Here’s a sample data set to emulate this type of data requirement (created in 11.1.0.6, 1MB uniform extents, freelist management and 8KB blocks).


create table t1 (
	state		varchar2(10),
	n1		number,
	v1		varchar2(10),
	padding	varchar2(100)
);

insert into t1
select
	decode(mod(rownum,100),0,'OPEN','CLOSED'),
	rownum,
	lpad(rownum,10,0),
	rpad('x',100,'x')
from
	all_objects
where
	rownum <= 5000
;

(more…)

December 15, 2010

Join Surprise

Filed under: Bugs,CBO,Execution plans,Oracle,Troubleshooting — Jonathan Lewis @ 8:54 pm UTC Dec 15,2010

Imagine I have a simple SQL statement with a “where clause” that looks like this:


	t2.id1(+) = t1.id1
and	t2.id2(+) = t1.id2

Would you expect it to run several times faster (25 minutes instead of a few hours) when the only change you made was to swap the order of the join predicates to:


	t2.id2(+) = t1.id2
and	t2.id1(+) = t1.id1

(more…)

December 14, 2010

Case Study

Filed under: Oracle — Jonathan Lewis @ 7:02 pm UTC Dec 14,2010

Ari Mozes (member of the Oak Table Network and Development manager at Oracle Corp.) has published an interesting series of articles on Data Mining. I’ve listed the URLs of three parts here for easy reference:

Note – Oracle Data Mining is an extra cost option to Enterprise Edition.

December 13, 2010

Categories

Filed under: Uncategorized — Jonathan Lewis @ 6:36 pm UTC Dec 13,2010

Whn looking for information and ideas on a topic I like to browse through a few items that might be related as this can help to prompt me to think about side effects and consequences that I might need to consider, so, to make it easier for people to find related information when searching my blog I’ve been adding a number of new categories to the list on the right, and adding URLs to the end of each article that generates a listing of all items in the same category as the original article.

To keep the mechanism useful I’ve set a limit of 10 articles for categories that I use in this way, and will try to ensure the category contains a set of articles that builds a useful picture of a topic rather than being a set of articles which just happen to contain the right key word.

The process is ongoing so some articles aren’t categorised in this way at present. Some articles belong to more than one category, of course, and there are some articles that aren’t sufficiently important to merit inclusion in a “further reading” list.

It would be nice if I could get the listings to appear in order of publication; unfortunately they appear in reverse date order. If anyone knows how I can change this, please let me know

Footnote: In a similar vein to making it easy to find related information – if you haven’t already noticed it I have a “random page” link in the first list in the right hand panel – this is largely for my benefit because I like to take a few minutes from time to time to read stuff I’ve written in the past. It’s a little task that lets me correct grammar, spelling, formats and, inevitably, the odd error – and sometimes it even reminds me to write the next part of a multi-part blog.

Index ITL fix

Filed under: Index Explosion,Indexing,Oracle,Troubleshooting — Jonathan Lewis @ 6:29 pm UTC Dec 13,2010

Over the last year I’ve written a short collection of articles describing how a defect in the code for handling index leaf (block) node splits can cause a significant waste of space in indexes that are subject to a high degree of concurrent inserts. Finally I can announce some good news – Oracle has a patch for the code.

The problem is described in MOS (the database formerly known as Metalink) under bug 8767925 which is reported as “fixed in version 12.1″.

Backports may become available – I’ve already asked for one for 11.1.0.7 on AIX for one of my clients (but’s it has been a little slow in arriving) and another client should have put in a bid for a backport to 10.2.0.4 (also on AIX) in the last couple of days.

December 10, 2010

Quiz Night

Filed under: Execution plans,Hints — Jonathan Lewis @ 6:19 pm UTC Dec 10,2010

I have four simple (non-partitioned, non-clustered, not views, not object type – really I’m not trying to be cunning or devious here) heap tables, and write a query that joins them:

select
	/*+
		leading(t1 t2 t3 t4)
		use_hash(t2) use_hash(t3) use_hash(t4)
	*/
	count(t1.small_vc),
	count(t2.small_vc),
	count(t3.small_vc),
	count(t4.small_vc)
from
	t1,
	t2,
	t3,
	t4
where
	t2.id2 = t1.id1
and	t3.id3 = t2.id2
and	t4.id4 = t3.id3
;


(more…)

December 9, 2010

Geek Stuff – 2

Filed under: trace files,Troubleshooting — Jonathan Lewis @ 6:50 pm UTC Dec 9,2010

This is a post specially for Junping Zhang, who has been waiting patiently for a follow-up to my geek post about find the system-level setting for parameter use_stored_outlines. His question was: “Is it also possible to find the session-level setting ?”

The answer is yes – but it’s harder, version specific, requires a little preparation, and only allows you to see the setting for your own session.
(more…)

December 7, 2010

Index Join – 3

Filed under: Execution plans,Index Joins,Indexing — Jonathan Lewis @ 6:01 pm UTC Dec 7,2010

I’ve recently been writing about the index join mechanism and ways of emulating it. Those notes were originally inspired by an example of an index join that appeared on OTN a little while ago.

It was a plan that combined “bitmap/btree conversion” with the basic index join strategy so, with hindsight, it was an “obvious” and brilliant execution plan for a certain type of query. The query in the original posting was a simple select (with no predicates) against a huge table in a data warehouse – presumably extracting a small number of columns from a much wider row.
(more…)

Next Page »

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 819 other followers