SELECT on a table in the INSERT statement uses the INDEX

Hello world

I have a strange problem with EA Oracle 10 g (64-bit) running on a Linux system. The situation is, I developed a Java program to migrate one client system to another. One of the steps in the migration fills a new table with the data from the old system. Given that the data on the old system structure is fundamentally different from that new, I have to check each time I read a line from the old system, if I have already created an entity on the new table, and if so, update certain attributes. The WHERE clause of this audit uses a key of the company indexed on the new table. The problem is now, that Oracle does not use the index on the key attribute of the company, but it makes table scans complete to select the line. As you can imagine, the lines first thousand or so go fast, but the amount increases, the program becomes slower and slower.

If I do a "scan" when executing the migration program, Oracle change the execution plan and use the index on the attribute key and everything works fast and smooth. However, if I do the analysis on the empty table first, nothing changes (which I understand it perfectly, since there is nothing to analyze, at this point). By integrating a hint of 'INDEX' (table) in the statement SELECT does not change the full implementation plan (also table scans).

Is it possible to change this behavior, in order to SELECT it uses the index of key business from the beginning?

Greetings from Cologne,

Thorsten.

Published by: thkitz on 13.03.2012 18:27

thkitz wrote:

SELECT STATEMENT  ALL_ROWSCost: 2  Bytes: 76  Cardinality: 2
     7 TABLE ACCESS BY INDEX ROWID TABLE AIDATINT.PRVVSSCHADENKORRESPONDENZ Cost: 2  Bytes: 76  Cardinality: 2
          6 BITMAP CONVERSION TO ROWIDS
               5 BITMAP OR
                    2 BITMAP CONVERSION FROM ROWIDS
                         1 INDEX RANGE SCAN INDEX AIDATINT.I_PRVVSSCHADENKORRESPONDENZ_1 Cost: 1
                    4 BITMAP CONVERSION FROM ROWIDS
                         3 INDEX RANGE SCAN INDEX AIDATINT.I_PRVVSSCHADENKORRESPONDENZ_2 Cost: 1  

I would have thought that as a plan as possible. It is not a concatenation, is a btree/bitmap conversion.
Allude to this plan you need / * + index_combine (table_alias index1 index2) * /.
For 10g and later the index can be specified by name or by description

I'm a bit puzzled why the plan changes after truncate - but maybe my comment about not cleared statistics is no longer true. It is easy enough to check if I'm right or wrong on your version of Oracle.

Concerning
Jonathan Lewis
http://jonathanlewis.WordPress.com
Author: core Oracle

Tags: Database

Similar Questions

  • Generate the insert statement using columns in view all_tab_cols

    I am trying to generate a dynamic insert statement using the columns of a table in the all_tab_cols view. If I do a select, I get the result as lines. How to convert the row of the columns so that I get something like this:
     INSERT INTO TABLE_NAME (COL1, COL2, COL3,COL4.....) 
    .

    Any help will be appreciated!

    This can give you a tip.

    SQL> ed
    Wrote file afiedt.buf
    
      1  with tab_col
      2  as
      3  (
      4  select i.table_name,
      5         column_name,
      6         row_number() over(partition by i.table_name order by table_name) rno
      7    from user_tab_cols i
      8  )
      9  select 'INSERT INTO '||table_name||' ('||ltrim(sys_connect_by_path(column_name, ','), ',')||')
     10    from tab_col
     11   where connect_by_isleaf = 1
     12   start with rno = 1
     13  connect by rno = prior rno+1
     14     and table_name = prior table_name
     15* and rownum<4
    SQL> /
    
    SQL_STATEMENT
    --------------------------------------------------------------------------------
    INSERT INTO A (MAKER,TYPE)
    INSERT INTO ADAM_TEST (ACCT,CODE)
    INSERT INTO AREA_TBL (AREA_ID,ORG_ID,CLUSTER_ID)
    INSERT INTO B (MAKER)
    INSERT INTO BONUS (ENAME)
    INSERT INTO CLUSTER_TBL (CLUSTER_ID)
    INSERT INTO COMPANY (MANUFACTURER)
    INSERT INTO COUNTRIES (COUNTRY_ID)
    
  • GRANT SELECT on a table to the user / role changes for the tab last_DDL

    Hello

    Is grant select (or any private object) to the user/role a DDL statement?

    GRANT SELECT on a table to the user / role changes the last_DDL to the table.
    1 > is this expected behavior?
    2 > no way in which we can grant select on a table by another user, without changing the DDL? (for example create view).


    The test is performed:

    Prior to the issuance:


    OBJECT_NAME CREATED TIMESTAMP LAST_DDL_TIME OWNER
    ------- ---------------------- ---------- ------------- --------------------
    AR HZ_CUSTOMER_PROFILES 8 MAY 00 13 MARCH 13 2003-06 - 26:12:41:29



    Grant statement:
    GRANT SELECT ON "AR". "' HZ_CUSTOMER_PROFILES ' TO 'AR_VIEW ';

    Note: AR_VIEW is a role, I tried granting also directly to the user.


    After the grant:

    OBJECT_NAME CREATED TIMESTAMP LAST_DDL_TIME OWNER
    ------- ---------------------- ---------- ------------- --------------------
    AR HZ_CUSTOMER_PROFILES 8 MAY 00 21 MARCH 13 2003-06 - 26:12:41:29



    Old thread, discuss whether Grant is DDL or not, but no documented conclusions.
    ( Re: Grant, revoke is DDL and DCL? )

    Please help in the assessment above.

    -Best regards,.
    Mani

    It's the DOF.

    After all, this isn't DML, it implicitly committed and you cannot use it directly in PL/SQL: features of DDL. :-)

  • Is it possible to create a shuttle component in Oracle ADF, where the available and selected lists are tables of the adf?

    Hi all


    We use JDeveloper Studio Edition Version 12.1.3.0.0 and deployed on GlassFish Server Open Source Edition 3.1.2.2 (build 5) and connect to the SQLServer database.


    Is it possible to create a shuttle component in Oracle ADF, where the available and selected lists are tables of the adf?



    I did a POC sample on it. I can share with you. I can't put in my dropbox because dropbox is blocked in my network. Share your email. I'll send the POC through

  • kindly tell how to use the unique value of a table with the index 0

    kindly tell how to use the unique value of a table with the index 0

    Hi
     
    Yep, use Index Array as Gerd says. Also, using the context help ( + h) and looking through the array palette will help you get an understanding of what each VI does.
     
    This is fundamental LabVIEW stuff, perhaps you'd be better spending some time going through the basics.
     
    -CC
  • Break down and an object of a list/table of the index reference

    TestStand using I'm trying to figure out how to break down and an object reference to a table/list of the index. My sequence is attached. I received a few tips of the 3rd developer with VB code, what should be done. I'm having a problem translating in TestStand. VB code follows the description.

    I use .NET to run a 3rd party software using a sequence of imagery system and run 3rd party software tests. In TestStand, my "GetCurrentTests" approach, when an object for a specific sequence reference, returns a reference of type object ' object reference(system.collections.generic.list'1[Radiant.Imaging.TSEngine.ICommand]); expected return a list of tests in the sequence of part 3.

    Next steps "GetCurrentPattern" needs to index through this list in order to get and then define and display the display model of the specific test to start the specific test. This next step class is RadiantImaging.TSEngine.ICommand (interface) and returns an object reference (radiantImaging.PatternGenerator.Patterns.Patternbase): a reference to the model.

    What I'm confused about is decaying of the 'object reference(system.collections.generic.list'1[Radiant.Imaging.TSEngine.ICommand])' return value in order to provide the? indexed reference object for "Model of GetCurrent" step.

    VB code is provided below for me that shows how it can be done in VB. I'm not familiar enough with TestStand, .NET and VB to break down this >

    Any suggestions or advice is greatly appreciated.

    VB code:

    Public Class Form1

    Private PatternGenerator.IPatternGenerator MPG

    Private WithEvents mTestSequence as TSEngine.TestSequence Private Sub InitializeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InitializeButton.Click

    TSEngine.Settings.MeasurementSource = TSEngine.MeasurementSources.Camera

    TSEngine.Settings.SaveMeasurementsToDatabase = False

    TSEngine.Settings.SaveResultsToDatabase = True

    TSEngine.Settings.SerialNumberAllowDuplicates = True

    mPG = TSEngine.CurrentPatternGenerator

    TSEngine.Initialize ("C:\PM 4616197.rdb Calibration")

    TSEngine.Databasename = "C:\default Alpha_PEK_Date.pts".

    TSEngine.InitializeCamera)

    End Sub

    Private Sub RunButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunButton.Click

    mTestSequence = New TSEngine.TestSequence (1)

    Dim result as TSEngine.Tests.ResultEnum

    For i As Integer = 0 To mTestSequence.NumberTests

    Dim p As PatternGenerator.Patterns.PatternBase

    p = mTestSequence.CommandList (i). Model

    p.PatternGenerator = mi/gal

    mPG.MonitorType = PatternGenerator.Monitor.PrimaryPartial

    ' p.PatternGenerator.MonitorType = PatternGenerator.Monitor.PrimaryPartial

    p.PatternGenerator = mi/gal

    p.Show)

    result = mTestSequence.RunSingleTest (i)

    Dim results As List (Of TSEngine.IResult) = mTestSequence.CommandList (i). Result

    Results (i). Name

    mTestSequence.CommandList (i). ResultMeasurement.

    Next

    End Sub

    Technical support solution: "I spoke with R & D and they informed me that the type of data in question is a generic class that is not supported with the .NET adapter. You can change the data type of a code module to another using a data type of object reference, but you can not manipulate the generic classes within TestStand.

    "" "" You can find this information in aid of TestStand under NI TestStand environment reference help"TestStand adapters" adapters for .NET ' adapter .NET '.NET called settings ' settings not supported. Here, the solution would be to ask a code module that performs this task for you. »

    Change the settings for call .NET

    Parameters not supported

    The TestStand .NET adapter cannot call methods and properties that have arrays as parameters in staircase or return types and does not support structures that have shredded the members of the group.

    In addition, the .NET adapter does not support creating or call methods on generic classes.

    My solution was to implement the foregoing in VB.NET from TestStand .NET adapter does not support .NET generic data types.

  • Query took too much time when adding new column to the table and the index set on this

    I added a new column to the table that contains thousands of records. and created the composite index with three columns (those newly added + two existing column)

    for the specifics. TBL table there are two columns col1, col2

    I added the new column col3 to TBL and created composit index (col1, col2, col3).

    Now for all the records in col3 is NULL. When I choose on this table, it takes too long...

    Any idea what my I do bad., I have check the query plan, it is using the index

    It is solved using collection of statistics using the

    DBMS_STATS. GATHER_TABLE_STATS

    @Top.Gun thanks for your review...

  • Shrink the table, rebuild the index?

    I need to reduce some very large tables after the removal of lines and I want to validate the script to run. I was thinking something like this:
    run_deleting_process;
    change the movement line of table my_tableI enable;
    ALTER table my_table retractable space WATERFALL;
    change the movement line of table my_tableI disable;
    I need to rebuild the index after that?, or if I rebuild the markings, can I delete clause CASCADE of the command? It is recommended to run utltrp.sql after shrink the table?, maybe some dependent object needs to be recompiled after the reduction of a table?
    The database version is 11.1.0.7 and documentation does not specify that the index rebuild is required, but I realized it is a desition normall when the narrowing of the tables.
    Thank you

    No there is no rebuild the index after shrinkage. And if you use "cascade", your index will be supported. You do very well.

    Visit this link as well.

    http://www.orafaq.com/Forum/t/137522/2/

  • Select from another table, when the query returns no result

    Hello

    I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.

    SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid

    Any help will be greatly appreciated.

    Thank you.

    user10407139 wrote:
    Hello

    I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.

    SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid

    Any help will be greatly appreciated.

    I think you need to explain more clearly if

    -you only have a couple of "billing" columns which is empty and in this case, you want to use the columns from the table 'accounts '.

    - or you have a join with another table that doesn't return data, for example a foreign key "address_id" "billing" is zero and therefore the join to other tables 'address' will return all the data

    In the first case, you have already been provided with some examples here, how to use NVL or similar functions to achieve, even if the first post first evaluates the information of 'accounts' and if it is white using information from "billing". According to your description you need the other way around. The second post a subquery recursive useless in my opinion.

    In the latter case, you should probably use an "outer" join so that the data in your table "bills" are returned, even if the join to another table is not at all the lines.

    SELECT
    NVL(AD1.ADDRESS_ATTR1, AD2.ADDRESS_ATTR1) as ADDRESS_ATTR1,
    NVL(AD1.ADDRESS_ATTR2, AD2.ADDRESS_ATTR2) as ADDRESS_ATTR2,
    NVL(AD1.ADDRESS_STREET, AD2.ADDRESS_STREET) as ADDRESS_STREET,
    ...
    FROM accounts a
    INNER JOIN billings b
    ON a.accountid = b.accountid
    LEFT OUTER JOIN address ad1
    ON b.address_id = ad1.address_id
    INNER JOIN address ad2
    ON a.address_id = ad2.address_id;
    

    In this way you pick up the address stored in the "invoices" table, if it existed, otherwise you pick up the address assigned to the "accounts" table I used an inner for the second address join join because you said that the account always has an assigned address.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • Line layout selection/evidence code table of the adf

    Hi all

    I use Jdev12c and you want to programmatically select a row in a table. It's the line should be highlighted and the graph of the child should also be updated to the selected line. If I can get one of these features that is also sufficient.

    I have DCIteratorBinding instance for the table, but do not receive good method/how to get there. The size of table is 20.

    Thank you!

    viewObject.setCurrentRow (row); did not work for me it turns that I greeted the multipleSelection on the table and this is the main reason for which even after refresh of the VO of the selection of some random lines in the main table is not removed even if detail table/chart refreshes to display the data corresponding to the first line of the main table.

    So I removed the selection of the main table (using following code) gives me the very view that when the page is loaded first time (i.e. no line selected in the child master and graph/table table were given corresponding to the first row in the main table).

            UIComponent component = JSFUtils.findComponentInRoot (tableId);
            If (component instanceof richeTableau) {}
                Table richeTableau = component (richeTableau);
                Set of rows RowKeySet = table.getSelectedRowKeys ();
                rowSet.clear ();
                System.out.println ("removed from the line selection table:" + tableId);
  • How to capture the event of selection of a table on the side line client (JavaScript)

    The example is:
    < af:table >
    < af:column >
    < af:outputText... >
    < af:clientListener... / >
    < /... >
    < /... >

    However, the text does not fill to the top of the cell. So, if I click on the on the empty area, the event handler is not called.
    I hope, even if I click on the empty area of the line, the event handler will be called.
    In fact, if I click on a row of a table at any location, including the empty area, the line becomes blue. How to capture this select event row on the client side?

    You can try file the client listener as a child under tag instead of the ?

    
    ...
    
    
    
    

    The above code should call a function in your js file called "handleTableDoubleClick", which, in turn, queued a ClientEvent that can be attached to a Backing Bean method. Something like:

    ...
        public void handleTableDoubleClick(ClientEvent ce) {
           //do something when the table is double clicked.
        }
    ...
    

    hope that helps

  • How to export select data from table in the file?

    Hello..

    Here's my query to select data in 2 tables and I join help call_id column: -.

    Select n.nbr_calling, n.nbr_called, c.tec, n.conversation_duration
    of albn_ngnsm_280110 n, albc_ngnsm_280110 c
    where c.call_id = n.call_id
    and c.route_to_arbor = 1;

    The problem is what is the query to export all the output in text files?


    Thank you
    Balleur

    Hello

    set echo off
    set heading off
    set pagesize 0
    set linesize 150
    
    spool D:\file.csv
    SELECT Query
    spool off
    

    Thank you
    Ankur

  • Referring to a Page Field in an INSERT statement used in a trigger

    Hi guys,.

    The following throws an error year I'm sure it's because of the way I am referencing the Alert_ID page 4... can anyone help with my bad syntax here please? .....  INSERT INTO am_alertevents (event_description, alert_id) VALUES ("Proposed Action",: P4_ALERT_ID);

    I hope that yoy can help,

    Richard

    Hi Jariola,

    I solved it!  I deleted my apex gross error management error and then got message that says that it does not assign the alert_id to NULL.  This made me think that after the present was in the wrong place to put this code as the value of P4_ALERT_ID can be bad at this moment there.  So I changed the code on submit and forward Compution and it works.

    Thanks for your help.

    Richard

  • How to revoke the SELECT on a table for a specific user?

    Environment:

    SQL * 3.1 on Windows XP Pro SP3 Developer to connect to Oracle 11.2.0.3 EE on Solaris 10.5.

    I have table T with SELECTION privilege granted on this issue both a role and a specific user.

    I am using SQL * Developer to revoke the privilege SELECT on this table of the individual user and leave the role.

    I can see how to revoke the role by right-clicking on the table and goes to the privileges-> revoke but I can't find where to choose a specific user to revoke of.

    Any help is greatly appreciated!

    -gary

    Hi Gary,.

    You are probably aware of the SQL syntax of base to make grant and revoke of SQL * more or the SQL Developer Worksheet:

    grant select on .T to ;
    revoke select on .T from ;
    

    To reach the equivalent to revoking of SQL Developer Connection Navigator...
    1. open the connection for
    2 expand the Tables node, and then open the object for table T browser.
    3. click on the grants tab and then, in its toolbar, select Actions->-> Revoke privileges
    4. Select in the drop-down list of the dialog box to remove user Action.
    5 shuttle privilege SELECT from the right back to the left, and then click apply.

    One would expect to be able to do the same thing from say the node under the node for the use of the SYSTEM for other users, but this isn't the case.

    Hope this helps,
    Gary Graham
    SQL development team

  • Problem to INSERT INTO using the stored procedure in 10g

    I use a 10g R2 database.

    I created two tables as follows:
    SQL > create table t1 (c1 varchar2 (1), number (1) c2, c3 number (1);)
    SQL > create table t2 (deptid varchar2 (4), empid varchar (4), varchar2 (1) c1, c2 number (1) c3 number (1);)

    insert into t1 values ('A', 3, 5);
    insert into t1 values ('B', 5, 5);
    insert into t1 values ('C', 5, 5);

    I want to create a stored procedure to insert data into table t1 t2 and certain parameters of the procedure.
    Is this possible?
    As an example:
    SQL > execute test (1,2)

    This procedure will be insert these two parameters in table t2 AND select rows in table t1 and insert into table t2 at the same time.
    How can I write the procedure?
    Tip:
    SQL > create or replace procedure
    (v_deptid, v_empid number)
    is
    BEGIN
    Insert into t2 (deptid, empid, c1, c2, c3)
    ... Select c1, c2, c3 from t1;
    end;

    My question is: How can I insert the v_deptid and v_empid parameters at the same time?

    Try

    SQL > create or replace procedure
    (v_deptid, v_empid number)
    is
    BEGIN
    Insert into t2 (deptid, empid, c1, c2, c3)
    Select v_deptid, v_empid, c1, c2, c3 to t1;
    end;

Maybe you are looking for

  • MacBook 2007 crashes after installation of the software

    HI all, I have a 2007 MacBook running snow leopard. OS X 10.6 (Snow Leopard) Office 2011 2.0 GHz Intel Core 2 Duo 2 GB of RAM 120 GB HDD I recently tried to install the software provided with spin, the usb controller algorithm Djay to he... Don't kno

  • Re: Can't turn off wireless on my Satellite L500-21dts

    I have problem with wireless that is I can t turn off. I have windows 7 and I installed the drivers on the site for this series but can t always turns off Wireless using FN + F8.My computer laptop doesn t have the manual button to turn off wireless!

  • How create/get ColorPal driver for LabVIEW?

    Hello! I am a french student in England and I'm working on the Starter Kit 2.0 (with DaNI Robot). My company wants to turn the feature of prevention of obstacle (thanks to the ultrasonic sensor) into a follower of colored (thanks to the Parallax Colo

  • Update security for Windows Vista (KB979683)

    Update security for Windows Vista (KB979683) I get "error (s) found: Code FFFFFFFF. Help, please!

  • I can not express outlook to send anything from craigslist

    I think I have outlook express right don't know if... signed up for an account with msn.hotmail... than went to outlook express, but can't send any what it says my email address is not fair