Invalidation of the index based on a function because the recompilation

Hello

one of our customers has two indices according to the functions that fall under the State "off" in some situations. After looking more closely at the situation, there are some things that my opinion are different from what I expected of a function-based index. Because I am unable to find anything about either on metalink (or I'm not asking the right question) I would appreciate a second opinion of you.

To keep things simple, I gave an example to illustrate the behavior. I use Oracle 12.1.0.2, although it can also be reproduced on versions 10.2 and 11.2.

It's my environment and three parameters that I find relevant to the discussion:

SQL> select banner from v$version;

BANNER
----------------------------------------------------------------------------

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
CORE    12.1.0.2.0      Production
TNS for Linux: Version 12.1.0.2.0 - Production
NLSRTL Version 12.1.0.2.0 - Production

SQL> show parameter remote_dependencies

NAME                                 TYPE        VALUE
------------------------------------ ----------- ----------
remote_dependencies_mode             string      TIMESTAMP

SQL> show parameter query_rewrite

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------
query_rewrite_enabled                string      TRUE
query_rewrite_integrity              string      enforced

Test case:

SQL> CREATE OR REPLACE FUNCTION f1 (p_string IN VARCHAR2)
  2  RETURN VARCHAR2
  3  DETERMINISTIC
  4  IS
  5  BEGIN
  6    RETURN lower(p_string);
  7  END f1;
  8  /

Function created.

SQL> CREATE TABLE tmp_t1 (a_string VARCHAR2(10));

Table created.

SQL> INSERT INTO tmp_t1 VALUES ('a');

1 row created.

SQL> COMMIT;

Commit complete.

SQL> CREATE INDEX x1_tmp_t1 ON tmp_t1(f1(a_string));

Index created.

SQL> set linesize 80;
SQL> column index_name format a10;
SQL> SELECT index_name, index_type, status, funcidx_status
  2    FROM user_indexes;

INDEX_NAME INDEX_TYPE                  STATUS   FUNCIDX_
---------- --------------------------- -------- --------
X1_TMP_T1  FUNCTION-BASED NORMAL       VALID    ENABLED

We have our table and our based on an index function which basically converts the values to lowercase. From here on things, download a little weird. What happens with the index based on a function if the underlying function is recompiled? I always thought (and which is also stated in the Concepts and the use of function index (Doc ID 66277.1)) that the index would change its status to "disabled". Here is an excerpt of the said Doc ID:

The index depends on the State of the PL/SQL function. The index can be

struck down or rendered useless by changes to the function. The index is marked

People with DISABILITIES, if he is brought to the function or function is re-created.

The timestamp of the function is used to validate the index.

To allow the index after it is created, the function if the signature of the

the function is identical to the front:

ALTER INDEX ENABLE;

If the signature of functions is changed, to make the changes effective

in the index, the index must be renewed to make it valid.

ALTER INDEX REBUILD.

It seems that this is not the case, as the index remains valid and activate.

SQL> alter function f1 compile;

Function altered.

SQL> SELECT index_name, index_type, status, funcidx_status
  2    FROM user_indexes;

INDEX_NAME INDEX_TYPE                  STATUS   FUNCIDX_
---------- --------------------------- -------- --------
X1_TMP_T1  FUNCTION-BASED NORMAL       VALID    ENABLED

OK, explicitly recompiling function F1 single timestamp changed. What if we replace the function completely and we change the output of the function - for example we will switch from a LOWER function to SUPERIOR function in the body of the F1. Again, it is change that I thought would be not only to disable the index based on a function, but also force its reconstruction. At least that is my understanding of the explanation in Doc ID).

SQL> CREATE OR REPLACE FUNCTION f1 (p_string IN VARCHAR2)
  2  RETURN VARCHAR2
  3  DETERMINISTIC
  4  IS
  5  BEGIN
  6    RETURN UPPER(p_string);
  7  END f1;
  8  /

Function created.

SQL> SELECT index_name, index_type, status, funcidx_status
  2    FROM user_indexes;

INDEX_NAME INDEX_TYPE                  STATUS   FUNCIDX_
---------- --------------------------- -------- --------
X1_TMP_T1  FUNCTION-BASED NORMAL       VALID    ENABLED

Should not be. Because of the function "create or replace" F1 never go through a "invalid" phase which may be necessary for index becomes unusable? What about queries on the TMP_T1 table? Does optimizer always uses access index or not? What about the results?

SQL> EXPLAIN PLAN SET statement_id='s1' FOR
  2  SELECT a_string, f1(a_string) as f1_a_string, f1('a') as f1_literal
  3    FROM tmp_t1
  4   WHERE f1(a_string) = 'a';

Explained.

SQL> SELECT * from table(dbms_xplan.display(statement_id=>'s1'));

PLAN_TABLE_OUTPUT                                                                                                   
------------------------------------------------------------------------------------------------------------------------
Plan hash value: 3133804460                                                                                         
                                                                                                                    
-------------------------------------------------------------------------------------------------                   
| Id  | Operation                           | Name      | Rows  | Bytes | Cost (%CPU)| Time     |                   
-------------------------------------------------------------------------------------------------                   
|   0 | SELECT STATEMENT                    |           |     1 |  2024 |     2   (0)| 00:00:01 |                   
|   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| TMP_T1    |     1 |  2024 |     2   (0)| 00:00:01 |                   
|*  2 |   INDEX RANGE SCAN                  | X1_TMP_T1 |     1 |       |     1   (0)| 00:00:01 |                   
-------------------------------------------------------------------------------------------------

The index is used by the optimizer, see the results.

SQL> column f1_a_string format a15;
SQL> column f1_literal format a15;
SQL> SELECT a_string, f1(a_string) as f1_a_string, f1('a') as f1_literal
  2    FROM tmp_t1
  3   WHERE f1(a_string) = 'a';

A_STRING   F1_A_STRING     F1_LITERAL
---------- --------------- ---------------
a          a               A

A_STRING = value in the table

F1_A_STRING = value of f1 (a_string) but the value is not evaluated because it comes from an index, so tiny value (remember, at the time index created the function returned small values)

F1_LITERAL = value of the function f1 newly evaluated, using literal instead of the value in the table.

Predicate f1 (a_string) = 'a' should return no rows because no character uppercase is equivalent to "a". Query with f1 (a_string) = 'A' should return a line, but it doesn't.

SQL> SELECT a_string, f1(a_string) as f1_a_string, f1('a') as f1_literal
  2    FROM tmp_t1
  3   WHERE f1(a_string) = 'A';

no rows selected

Anyone know if this is an expected behavior? And, is it possible to disable the index based on a function whenever the underlying function signature is changed? The parameter query_rewrite_integrity = applied from

DOC-ID 66277.1 does not seem to do the trick:

(c) session variables

~~~~~~~~~~~~~~~~~~~~

QUERY_REWRITE_ENABLED (true, false),

QUERY_REWRITE_INTEGRITY (confidence, forced, stale_tolerated)

determines the optimizer to use index based on a function with

expressions using SQL, user defined functions functions.

TRUST: Oracle allows rewrites using relationships that have

was declared.

APPLIED: Oracle ensures and guarantees consistency and integrity.

STALE_TOLERATED: Oracle allows rewrites using vessels of the relationship not applied.

Used in the case of materialized views.

Set session variable cost function optimizer to choose the

a function-based index

Kind regards

SAMO

From the Manual 11.2 ( https://docs.oracle.com/cd/E11882_01/appdev.112/e41502/adfns_indexes.htm#ADFNS254 )

"If you change the semantics of a DETERMINISTIC run and recompile, then you must manually rebuild all addicts depending on index and materialized views." Otherwise, they report results for the previous version of the function. »

This note is not that I made my initial comment well - which was based on an incorrect memory the relationship between function-oriented and autonomous pl/sql functions, so I won't try to explain it. In fact, I went back to Oracle 8i practice to see if something had changed between yesterday and today and found that I had described exactly the behavior that the OP has been seeing. It's the way it is supposed to be.

Concerning

Jonathan Lewis

Tags: Database

Similar Questions

  • Syntax for the existing index based on a function

    Hello:

    I'm on 10.2.0.3.

    Below is the list of indexes and the columns in the index on one of the tables. Aparantly one of the columns (SYS_NC00220$) is actually a function-based index.

    Anyone know how to get the SQL syntax for this index? TIA.

    INDEX_NAME UNIQUENES COLUMN_NAME POSITION_COLONNE
    ------------------------------ --------- ------------------------------ ---------------
    PS0BI_HDR not BILL_TO_CUST_ID 1
    PS0BI_HDR don't BUSINESS_UNIT 2
    PS0BI_HDR only SYS_NC00220$ 3
    PS1BI_HDR not BILL_STATUS 1
    PS1BI_HDR don't BUSINESS_UNIT 2
    PS1BI_HDR only SYS_NC00220$ 3
    PS2BI_HDR not CONTRACT_NUM 1
    PS2BI_HDR don't BUSINESS_UNIT 2
    PS2BI_HDR only SYS_NC00220$ 3
    NON-UNIQUE PSABI_HDR BILL 1
    PSABI_HDR don't BILL_TO_CUST_ID 2
    PSABI_HDR don't BUSINESS_UNIT 3
    PSABI_HDR not BILL_STATUS 4
    UNIQUE PROCESS_INSTANCE PSBBI_HDR 1
    UNIQUE BUSINESS_UNIT PSBBI_HDR 2
    INVOICE SINGLE PSBBI_HDR 3
    UNIQUE BUSINESS_UNIT PS_BI_HDR 1
    UNIQUE SYS_NC00220 PS_BI_HDR $ 2

    query user_ind_expressions and search for COLUMN_EXPRESSION.

    This will give you an expression.

  • How to create indexes based for TO_CHAR function

    I need to create an index of feature based for the to_char.when function I tried, I got an error, "only pure function can be indexed".which the error really means, help me in the creation of the index in order to reduce my query cost.

    It works fine on my database. version 9iR2

    create index IDX_TO_CHAR on emp(to_char(hiredate,'YYYY-MM-DD HH24:MI:SS'));
    
    explain plan for
    select hiredate from emp where to_char(hiredate,'YYYY-MM-DD HH24:MI:SS')='1981-05-01 00:00:00';
    
    ---------------------------------------------------------------------------------
    | Id  | Operation                   |  Name        | Rows  | Bytes | Cost (%CPU)|
    ---------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |              |     1 |     8 |     2  (50)|
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP          |     1 |     8 |     2  (50)|
    |*  2 |   INDEX RANGE SCAN          | IDX_TO_CHAR  |     1 |       |     2  (50)|
    ---------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access(TO_CHAR("EMP"."HIREDATE",'YYYY-MM-DD HH24:MI:SS')='1981-05-01 00
                  :00:00')
    

    Your not seem to be a setting issue, then why not give us your sql and execution plan and so on.
    There may be other ways to solve your sql as the creation of a function based index?

  • Based on a function index

    Hi all

    Based on a function index are recommended to sql queries slow poor acceleration?


    Thank you

    Kinz

    The only thing that a function index based (FBI) is intended is so you don't lose the use of an index when you call a function in your WHERE (predicate) clause.

    Not sure, I would say it was "the only thing"...

    How about you, the ability to provide access to a very small percentage of rows that match a certain condition (using DECODE or CASE) effective index?

  • My apple ID became invalid after the recent upgrade to ios 9.3

    My apple ID became invalid after the recent upgrade to ios 9.3. What can I do to reactivate the ID? I tried to reset my password several times even.

    For now, I am unable to pay for anything because I can't access the function of apple on the phone pay.

    Hello

    Follow the instructions here, include a link to get help from Apple with your Apple ID:

    If your identifier Apple is locked - Apple supports

  • How to model a view based on a function table

    Hello

    I want to model a view in SQL Developer Data Modeler which is based on a function of painting as:

    table (function (a, b))

    When the function is a function table in pipeline. How is that possible?

    DM 3.3.0.734 SQL version

    Best regards

    Joop

    Hello

    In the Properties dialog box of the view that is displayed when you create the view, you can select the Report Builder queries (on the general page) button.

    In the query designer, you can enter the query text in the box above the buttons OK and apply, cancel, for example
    SELECT * FROM TABLE (FUNCTION (a, b))

    David

  • Context of the sequence becomes invalid when the runtime is longer

    I have a sequence that loop for about 70 k iterations (which is pretty huge). The sequence called a subsequence where the inhabitants of the sequence called are modified. Question is, around 65 th iteration k, I get an error message indicating that the reference of the local past is invalid. The number of iterations when the error occurs varies from one computer to another, but always in the 65 k range. When I try to run another sequence (a single) consecutively, I get an "out of memory" error I guess the reason why the local reference is not valid because TS execution stops when the memory TS gets the complete decision-making context of sequence and therefore the reference local section not valid.

    I would like to know how to reduce the consumption of memory of TS because I disabled the result of record for all the result of sequences (Configure-> Options of Station-> run), disabled registration for each iteration of the loop, optimize no reentrant calls thi sequence is also enabled. I even tested with just this sequence of sequence and I wonder if there is a maximum number of threads of execution when a loop.

    PC configuration

    RAM-12 GB

    LabVIEW and Teststand 2010 SP1

    I will not be able to view the code, but the closure is a custom step which has sequence call as its adapter.

    Hello

    I tried this:

    Main sequence called a sub sequence, which includes 3 stages of instruction.

    I have a loop sequence sup to 75 k with result logging enabled.

    TS runs successfully - no problems.

    Try to jump steps (one at a time) in the sequence of sub to know at what stage leads to this question.

    Also try to reproduce using a simple sequence (that you can post online).

    Ravi

  • HP ENVY 360 M6: Wfii adapter on new 360 M6 desire becomes invalid after the last critical update.

    The wireless adapter on my new laptop becomes invalid after the last critical update. Reboot / restart, diagnosis or troubleshoot cannot fix or repair. I was forced to do a restore to the date preceding the update. Adapter Ok now? This is a problem on other models?

    Hello

    Try this first

    Download and install the latest driver of wireless LAN adapter can solve common problems with wireless Internet. Follow these steps to use the Device Manager to find the latest WLAN driver:
  • I cannot perform certain functions because he says that I'm not an administrator, but it's my computer and I'm the only one who uses this computer__

    I cannot perform certain functions because he says that I'm not an administrator, but it's my computer and I'm the only person who uses this computer

    What are the functions? More global changes (changes to the system, software installation) require an elevation in Vista/Windows 7.

    Changes to the built-in Vista administrator account

    http://support.Microsoft.com/default.aspx?kbid=942956

    User - recommended configuration (Vista and Win7) accounts

    You absolutely don't want to have only one user account. As XP and all other Windows 7, Vista, and modern operating systems are operating systems multi-user with integrated system of accounts as default Administrator and comments. These accounts should be left alone because they are part of the structure of the operating system.

    In particular, you do not want account only one user with administrator privileges on Vista and Windows 7 because the administrator account integrated (normally only used in emergencies) is disabled by default. If you use as an administrator for your daily work, and this account is corrupt, things will be difficult. It is not impossible to activate the built-in administrator to rescue things, but it may require more work you want to do. Better not to get into a bad situation at first.

    The user account that is for your daily work must be a Standard user, with the extra administrative user (call it something like 'CompAdmin' or 'Tech' or similar) only it for elevation purposes. As a user Standard is recommended for security reasons and will help protect your computer against infections. After you have created "CompAdmin", connect to it and change your normal user account Standard. Then log on to your regular account.

    If you want to go directly to the desktop and ignore the Welcome screen with the icons of the user accounts, you can do this:

    Start Orb > Search box > type: netplwiz [Enter]
    Click continue (or provide an administrator password) when you are prompted by UAC

    Uncheck "users must enter a user name and password to use this computer". Select a user account to connect automatically by clicking on the account you want to highlight and press OK. Enter the password for this user account (when it exists) when you are prompted. Leave blank if there is no password (null). MS - MVP - Elephant Boy computers - don't panic!

  • The account name is not valid, or the password is invalid for the account specified using Cobian Backup 11 name

    I did a new install of Windows 7 Professional on a workstation, and after all the updates, I installed Cobian Backup 11.

    When you set up backup Coabian first, the message "the account name is not valid, or the password is invalid for the specified account name" was shown.

    I went into the "services.msc" to manually set the password for the connection (the machine connects in a Windows Server 2003 domain), but when entering the dialog (properties/connection/account/local/search/select where you want to search for.) only the 'local computer' is displayed.

    I tried to enter the domain/user and the password manually, I logged in as administrator, I have excluded the uder from the server and have included him again, that I did everything in my mind but I couldn't solve the problem.

    Any help is welcome.

    TKS in advance.

    PS: Someone asked me what support Cobian said about it. To be honest I did not support Cobian because the other four machines were all as one that has the problem and two "local computer" and "directory of the whole area" appears.

    This retail driver to believe that the problem occurred is on the installation of windows 7 Professional.

    Hello

    We have dedicated support team for users on a domain network. I suggest you to report your query in the TechNet forums to improve assistance in this regard.

    Here is the link:

    http://social.technet.Microsoft.com/forums/Windows/en-us/home?category=w7itpro&filter=AllTypes&sort=lastpostdesc

    Hope this information helps.

  • The data specified in the request is invalid. The value of the field id package is not a MultipleLiteral, but the field is defined as MultiValued

    We have a property in a component software which is an array. the value is [""]

    In the blueprint I am sitting a value property ['vim', 'emacs'] defalult

    When I ask this plan and change the values of foo, bar, I get this error

    The data specified in the request is invalid. The value of the field id package is not a MultipleLiteral, but the field is defined as MultiValued

    someone knows why this happens?

    I'm runnign vra7.0.1

    Strangely, it works if

    Overridable is set to NO

  • Problems to install the plugin extension of Nexus 1000v vCenter file "invalid URI: the URI is empty.

    Hi all

    I try to install the Cisco Nexus 1000v switch in my training lab.

    When I get to the stage where I add the Extension XML file to the vSphere Plugin Manager, I get an error stating that "invalid URI: the URI is empty.

    When I open the cisco_nexus_1000v_extension.xml file, obviously, there is something missing in the & lt; URL & gt; & lt; / url & gt; section.

    Issues related to the:

    1 has anyone successfully installed the Nexus 1000v switch?

    2. If Yes, can you put the file extension xml so I can look at and compare?

    3. How can I delete the old file with extension of the Plug-ins available from the plugin Manager section? At the moment he is stuck on download and install...

    Thank you, Randy

    Mine is working

    do not worry about the error, mine still has the error when you click Download, all he has to do is see the upward

    Follow the steps on the site of cisco http://www.cisco.com/en/US/docs/switches/datacenter/nexus1000/sw/4_0/install/software/guide/install_n1000v.html

    If you want to delete the plugin and get a new use of one the steps here http://www.cisco.com/en/US/docs/switches/datacenter/nexus1000/sw/4_0/troubleshooting/configuration/guide/trouble_3install.html

    I followed the guides and got mine working

    can not post my xml because it is at home and I'm at work

    Chris

  • failure of pre-flight print saved PDF files through the "save under" function because of the current JavaScripts

    How can I disable using JavaScript in a PDF file that is saved with "Save as" option? PDF files print via postscript and distill are without JavaScript. PDF files that contain any JavaScripts fail the printing process before the flight and so we need to know how to disable all the JavaScripts in a PDF file even if Save as function is used to generate a PDF file.

    Thank you

    Peter

    Peter,

    I looked a little more on it, and regardless if you're reviewing post-processing routines or not, it seems that FM now always writes a javascript model when you use the SaveAsPDF routines. The script is actually empty, that is, it identifies the source as coming from FM, and here is the script embedded in the PDF document [he hasn't]:

    //

    FrameMaker

    //

    / * belongs to: Document-level: FrameMaker * /.

    //

    //

    It seems that your options are limited here. You cannot use the SaveAsPDF road and get rid of the script to the end of the FM of things. So you can use AcrobatPro to sanitize the document, create a script that will remove the javascript or talk to your printing provided by supplier to see if they will let the script above spend their pre-flight.

    Alternatively, use the print function to create your postscript and then distilling to create the final print-ready PDF. If you need to create a CMYK & Spot ready color output using the way of printing, then you will need to use GrafikHuset (today a freebie) PubliPDF in postscript output FM CMYK + Spot PDFs. download convert RGB:http://design.grafikhuset.dk/index.php/kontakt/downloads/grafikhuset-publi-pdf and more details available at the: http://www.grafikhuset.net/PubliPDF/

  • views get invalid when the procedure is changed

    Hello
    When a procedure is changed and therefore newly compiled some views according to are reported as 'invalid '. For this reason the following application generates errors. How could it be created to complie based on all of the objects (e.g. views) when the procedure gets compiled?

    Rgds
    Jan

    The coil of the output of the select statement in a file and then run the file:

    Select 'Edit'. "replace (object_type, 'BODY of PACKAGE', 'PACKAGE') | '|| object_name |' compile; »
    from user_objects
    When status = 'INVALID';

    It compiles all invalid objects of a user. After execution, you can repeat the step if the compilation of an object struck again a few other objects - select till does not any new release.

    Kind regards
    Monika

  • Invalid certificate, the page displays past date, CERT. is the correct date.

    This is the message I get:

    "login.yahoo.com uses an invalid security certificate. The certificate will be more valid until 02/03/2014 18:00. "The time now is 17:09 07/02/2014 (error code: sec_error_expired_certificate).

    The problem is that (the date I wrote that) is today 07/03/2014. The specified time is accurate, but the date is one month old. I checked the time on my computer and router and both are accurate. Is there another place where Firefox gets its timestamp? I do not understand why the date used for the certificate would be turned off by a whole month. This problem appeared on the 04/03/2014.

    Firefox still seems to think that the date is wrong, if the current time is 17:09 07/02/2014.

    You can see the time and the time zone if you paste this code in the line of command of the Web Console (Web Developer > Web Console;) CTRL + SHIFT + K)

    • console.log ((nouvelle_Date).toLocaleString ()); Use it to get your current time zone time

Maybe you are looking for