Re: Function Based Index

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Tue, 11 Sep 2012 13:48:31 +0100
Message-ID: <57F36CFE547C435EB30B29319CAC8E99_at_Primary>



Purav,

If you've got the execution plan it's a good idea to show it - it can make it easier to explain the problem.
As it is, I've just run up a little test case - I'll be writing it up some time this evening probably- that suggests it's a bug.

A simple delete by index is usually costed simple as the cost of "select rowid from table", but for a function-based index the operation "table access by rowid" also appears in the plan. In some versions of Oracle this operation is NOT costed (or given a cost of zero) so the delete is cheap, in other versions of Oracle it is costed, and can make the delete very expensive.

Regards

Jonathan Lewis
http://jonathanlewis.wordpress.com/all_postings

Author: Oracle Core (Apress 2011)
http://www.apress.com/9781430239543

  • Original Message ----- From: "Purav Chovatia" <puravc_at_gmail.com> To: "Stefano Cislaghi" <s.cislaghi_at_gmail.com> Cc: <Brandon.Allen_at_oneneck.com>; <oracle-l_at_freelists.org> Sent: Tuesday, September 11, 2012 9:36 AM Subject: Re: Function Based Index

| KEEP pool is configured for the instance. And the table's buffer_pool
| attribute is set to KEEP.
| Also, we use ALTER TABLE TABLE_NAME CACHE;
| Could that be the reason for either of the observations that I have made?
|
| The table has approx.14million rows. There are 3 columns and 1 of those
is
| a DateTime column which is updated with sysdate value if the record
exists
| else a new record is inserted with sysdate value in the DateTime column.
| Most of the times, the record exists and hence it results in an update.
|
| FBI is on the DateTime column.
|
| DML (expected to use the FBI): delete from <table_name> where
| trunc(datetime) < (trunc(sysdate) - 31) and rownum < 1000;
|
| Table contains data for last 31 days. The number of rows to be deleted is
| very small, say just over 200k.
|
| Pls let me know if I should provide any other info.
|
| Thanks
|
| On Mon, Sep 10, 2012 at 9:28 PM, Stefano Cislaghi
<s.cislaghi_at_gmail.com>wrote:
|
| > I agree. Anyway if you do not provide us more information and the
| > query anything we might say are only theory and guessworks.
| >
| > Ste
| >
| > On 10 September 2012 17:48, Allen, Brandon <Brandon.Allen_at_oneneck.com>
| > wrote:
| > > Maybe the CBO is choosing not to use the index because the percentage
of
| > blocks it thinks you will need is too high? I don't know exactly how
the
| > CBO calculates it, but the general rule of thumb is to only use an
index if
| > you're going to read less than 5% of the table's blocks. If the values
in
| > your look up column are skewed, you could try running the query with an
| > unpopular value such that Oracle will be more likely to use an index
(make
| > sure you flush the old plans out of the pool first), and then, if it
does
| > load the plan with the index, you can create a sql plan baseline to
make it
| > stick with that plan for future executions - that is assuming you're on
| > 11g; create a stored outline if you're on 10g.
| > >
| > > Regards,
| > > Brandon
| > >
| > >
| > >
| > > ________________________________
| > >
| > > Privileged/Confidential Information may be contained in this message
or
| > attachments hereto. Please advise immediately if you or your employer
do
| > not consent to Internet email for messages of this kind. Opinions,
| > conclusions and other information in this message that do not relate to
the
| > official business of this company shall be understood as neither given
nor
| > endorsed by it.
| > > --
| > > http://www.freelists.org/webpage/oracle-l
| > >
| > >
| >
| >
| >
| > --
| > http://www.stefanocislaghi.eu
| >
| > The SQLServerAgent service depends on the MSSQLServer service, which
| > has failed due to the following error: The operation completed
| > successfully.
| >
|
|
| --
| http://www.freelists.org/webpage/oracle-l
|
|
|
|
| -----
| No virus found in this message.
| Checked by AVG - www.avg.com
| Version: 2012.0.2221 / Virus Database: 2437/5261 - Release Date: 09/10/12
|

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Sep 11 2012 - 07:48:31 CDT

Original text of this message