Foreign key and index

In our table:
Table Name:
STATUS
Columns:
STATUSID NUMBER (PKEY)
USERID NUMBER (FKEY)
PATIENTNAME VARCHAR(30)
STATUS_DATE DATE
CREATE_DATE DATE
CHSTATUS VARCHAR(30)
PAYER_STATUS VARCHAR(30)
CHARGE_AMOUNT DOUBLE
INS_AMOUNT DOUBLE
X12IN CLOB
We have a foreign key on the USERID column. And this column appears in the WHERE clause always.
I wanted to know in addition to the foriegn key constraint, putting an INDEX on the USERID column will help query performance?
Generally speaking:
I wanted to know whether in oracle putting a foreign key constraint on a column creates an INDEX automatically or do I put the index specifically besides the FOREIGN key.
Thanks in Advance,
Rumpa Giri

Hello
Oracle does NOT create an index when you put a foreign key constraint on a column, so you need to create one if you want one.
Have a look at this discussion on asktom to understand when and why indexes on foreign keys are a good idea.
If your query that uses USERID in the where caluse returns a small number of rows in proportion to the number of rows in the table, adding an index could well help with query performance....but as always, it's best to benchmark it and get some stats that you can then use to make an informed choice.
HTH
David
Message was edited by:
david_tyler

Similar Messages

  • Binding for table produces list for other tables using foreign key and crea

    Using
    software Jdev 11G, WLS 11G, Oracle DB 11G, Windows Vista platform
    technology EJB 3.0, jspx, backing beans, session bean
    I cannot create a namedquery on my secondary table. The method for the column uses the entity object rather than the name and value of the column.
    For instance,
    (Coketruck) table has inventory records(Products) table
    Coketruck has one to many to the Products table
    Products has a many to one to the Coketruck
    I need to return the products from the product table based on the CokeTruck but I cannot create a namedQuery because the method in the Product table is an entity object type instead of a long that I can use to look up all the products based off the column truck_id.
    This is what I was expecting…
    Private Long truckId;
    public Long getTruckId() {
    return truckId;
    public void setTruckId (Long truckId) {
    this. truckId = truckId;
    Instead this is what I have…
    @ManyToOne
    @JoinColumn(name = "TRUCK_ID")
    private Coketruck coketruck;
    this. coketruck = coketruck
    public Coketruck getCoketruck() {
    return coketruck;
    public void set Coketruck (Coketruck coketruck) {
    this. coketruck = coketruck;
    How do I do a query on the Product table to return all the products that are in the coketruck?
    If I do the following it expects for me to pass the Entity Object which I cannot use as search criteria for my find method.
    @NamedQuery(name = "Products.findById", query = "select o from Products o where o.truckId = :truckId")
    On a different note but the same song…
    I noticed that when I look at my Session Bean Data Contols that the coketruck already has a list of the products. I have created a jsp page with a backing bean and have been able to use the namedquery on the coketruck entity to retrieve the productList. Unfortunately I need to sort the products by type and was also not able to find where to perform the work to be able to iterate through the productList to get my desired display. Therefore I started looking at doing another namedquery that would only retrieve the product_type ordering by the truckId.
    Seems I have come full circle… I don’t care what method I have to use to get the info back.
    Any help is greatly appreciated!

    user9005175 wrote:
    Hi!
    I work on an application wich uses a shopping cart stored in a database. The shopping cart uses two tables:
    CART: Holds information common for one shopping cart: the user it is connected to etc.
    - Primary key: CART_ID
    CART_ROW: One row in the cart, e.g. one new product to buy.
    - Primary key: ROW_ID
    - Foreign key: CART_ROW.CART_ID references CART.CART_ID
    From the code the rows in the cart are collected per cart, as is modelled by the foreign key. There exists one more relationship, which we use in the code, but which is not modelled by a foreign key in the database. One row can be dependent on another row, which makes the other row a parent.
    CART_ROW has a column PARENT_ID which references CART_ROW.ROW_ID.
    Should we add a foreign key for PARENT_ID? Or are there any questions to consider when it is a foreign key to the same table?
    I suggest to add foreign key it wont harm the performance (except while on insert when there would be validation for the foreign key). But it would prevent users to insert wrong/corrupt data either through code or directly by loggin in the database.
    A while ago we added indexes, both on ROW_ID and on PARENT_ID. Could the index on PARENT_ID have been harmful, since there is no foreign key?
    Index on parent_id would only be harmful if you do not make use of index after creating it (i.e. there is no query which make use of this index).
    And if you decide to have a foreign key on parent_id then I suggest to have index too on parent_id as it would be helpful atleast when you delete any record in this table.
    Best regards!

  • Assigning primary key and index for a table

    I have a database consisting of only one table with 10 million rows which mostly looks like this:
    RECORDDATE                     ID     CLASS     VALUE
    24-JAN-12 10.52.47.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     10     156
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     10     156
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     3     0
    24-JAN-12 10.52.48.000000 AM     96     6     38
    24-JAN-12 10.53.05.000000 AM     253     16     197
    24-JAN-12 10.53.06.000000 AM     98     10     150
    24-JAN-12 10.53.06.000000 AM     98     0     0
    24-JAN-12 10.53.06.000000 AM     98     4     0
    24-JAN-12 10.53.06.000000 AM     98     11     33As you can see there are several entries that look exactly the same. Currently, I don't have primary key or index for any column and have a lot of performance issues. For example this query takes more than 10 seconds to run:
    select distinct      ID
    from      scdatabase4
    where ID < 253
    order by 1Since database is not my primary job and have no background of it, I'm really confused about what to do to fix my issues. Could someone please help me in assigning primary key and index if you agree that this is the problem?!

    Execute the query below to help decide what column to index:
    SELECT COLUMN_NAME, NUM_DISTINCT, NUM_NULLS, NUM_BUCKETS, DENSITY
    FROM DBA_TAB_COL_STATISTICS
    WHERE TABLE_NAME = 'your_table_name'
    ORDER BY COLUMN_NAME;
    The important columns are:
    1) NUM_DISTINCTS: Indicates the number of distinct values. If this number is very low for a column, it indicates that this column is not a very good candidate for a B-Tree index.
    2) NUM_NULL: Indicates the number of null values for each column. A column with few null values is a good candidate for a index
    But be aware, this is not a rule, it's just a method to help decide which column will have the most benefit of index creation.

  • Drop foreign keys and recreate foreign keys with on delete cascade dymanica

    I need to drop foreign keys and recreate foreign keys with on delete cascade dymanically via a script. Does anyone have a script available?

    You could also disable the integrity contraints.
    SET PAGESIZE 0
    SET FEEDBACK OFF
    SET PAUSE OFF
    -- create a disable script
    SPOOL do_disable.sql
    SELECT 'ALTER TABLE '
           || table_name
            || chr(10) ||
           'DISABLE CONSTRAINT '
            || constraint_name
            || ';'
      FROM user_constraints
    WHERE constraint_type = 'R'
       AND status = 'ENABLED'
    select 'alter trigger '
           || trigger_name
            || ' disable;'
      from user_triggers
    where status = 'ENABLED'
    SPOOL OFF
    -- now create a enable script as well
    SPOOL do_enable.sql
    SELECT 'ALTER TABLE '
           || table_name
            || chr(10)
            || 'ENABLE CONSTRAINT '
            || constraint_name
            || ';'
      FROM user_constraints
    WHERE constraint_type = 'R'
       AND status = 'ENABLED'
    SELECT 'ALTER trigger '
           || trigger_name
            || ' ENABLE;'
      FROM user_triggers
    WHERE status = 'ENABLED'
    SPOOL OFF
    SET FEEDBACK ONif you run this script on a TESTdatabase you will end up with a do_disable.sql and a do_enable.sql script on youre local directory.
    Running do disable will disable all the currently enabled triggers and contraints.
    Running do_enable.sql will enable the previously disables triggers and contraints.
    be sure to test before executing this on a real live production database.
    Make sure you have a good backup!

  • Storage for Foreign Keys and Function based indexes

    This may well be the silliest question of the day, but is it possible to specify the storage for a Foreign key or a function based index? I'm not even sure that it would make sense.

    Well, a foreign key constraint is not a segment, nor is any other type of constraint. However, a function-based index is a segment, just like any other index. So, in that case, specify a tablespace, just like you would with any other index.
    Something like this:
    create index my_fbi on my_tab(upper(last_name)) tablespace my_index_tablespace;
    -Mark
    Message was edited by:
    mbobak
    Fixed minor typo.

  • Lack of Primary and Foreign Keys and Efficiency

    I am reverse engineering a Maximo database. I am shock that it does not have Primary or foreign keys define for 590 out of 620 tables.
    My question is does the lack of Primary and Foreign key relationships adversely impact the efficiency of an Oracle database? I think it does IBM techs do not think it does.
    Anyone has the answer?

    does the lack of Primary and Foreign key relationships adversely impact the efficiency of an Oracle database? Not necessarily. There are many large OLTP databases that do not define PKs and FKs.
    It is true that the presence of constraint defintions is used by the optimizer. However,
    what matters is how the application is written and how the optimizer handles it.
    Remember that Oracle Databases have been in production since before constraint definitions were introduced.
    Hemant K Chitale
    Edited by: Hemant K Chitale on Jun 9, 2010 10:05 AM

  • JDeveloper 9i, Foreign Keys and LOVs.

    Greetings all,
    I'm using Jdev 9i to try and create some maintenance applications quickly. These applications are pretty standard; insert, update, delete, some validation, including foreign keys.
    The problem is, I can't figure out how to get JDev to generate the JSPs with LOV pages on the foreign keys.
    I've tried setting the validation properties of the entity object to validate from a query, as well as, tried using View objects for the same validation. Neither get me results.
    I've also tried embedding the LOV directly using the LOVInputSelect (or whatever it is called). That works partially by displaying a field and a button, but when I click on it, I get an error with no explanation. Very helpful.
    I can use a InputSelect datatag, but it is not the best choice for foreign keys with hundreds of values.
    Also, since the Wizards are generating the DataEdit tag for the JSP I'm using, it appears that I cannot override them to display the LOV. They display a Calendar page for dates, automatically, but won't display an LOV for referential integrity. At least, I can't figure out how to make them.
    Thanks in advance.
    Ed Dana
    Software Developer.

    It's really beyond me why Oracle haven't provided a fairly complete set of Renderers (and a bit more BC4J oriented than the one's mentioned in the HOWTO).
    Basically, you have two choices:
    1/ develop your own Renderers (make your own conventions with Properties on Entities/ViewObjects) and use InputRender
    2/ generate the JSP's yourself using the usual jbo tags (probably again based on some meta data in the properties). You may have to fiddle around a bit with inputselectlov etc.
    Again, it's hard for me to understand why Oracle haven't substantially improved their default generated BC4J JSP pages, it looks to me that it is not so hard (compared to some of the other things they're trying to pull off) and gives maximum benefit for the customers.
    Alternatively, there is JHeadstart (do a search on otn, you'll find some pointers). It generates lots of screens nicely for you (a la Designer, if you're familiar with that). Some teething problems, but really very productive otherwise. The disadvantage here is that if you want to start to make a few little changes outside what it supports, you're up against a fairly steep learning curve to master UIX and MVC framework. Apparently there's some hope that they will generate to Struts (taglibs & controller, if I understand well) soon.

  • Foreign Keys and import of tables (ORA-02297)

    How can i get all the foreign keys for a particular schema, basically i'm trying to import tables into a particular schema so i'm trying to disable the constraints, truncate the table , import data and then enable the constraints.
    but i'm having error like these when i disable all the constraints in this particular schema
    Table altered.
    alter table STANDINGS disable constraint P_STANDINGS
    ERROR at line 1:
    ORA-02297: cannot disable constraint (SCDAT.P_STANDINGS) - dependencies exist
    alter table STANDPMTS disable constraint P_STANDPMTS
    ERROR at line 1:
    ORA-02297: cannot disable constraint (SCDAT.P_STANDPMTS) - dependencies exist

    I use a dynamic SQL-Plus script to generate all the constraints for a schema. I then run this SQL to disable the constraints. Sometimes need to run the script more than once depending on the order the constraints are disabled. Once your scripts runs clean, then you can truncate your tables, import your data, and re-enable constraints.
    To re-enable, just use and editor to do REPLACE DISABLE WITH ENABLE....
    Here is sample of my dynamic sql. Needs to be run as SYSDBA...
    set heading off;
    spool c:\disable_constraints.sql;
    select 'ALTER TABLE ' || owner || '.' || table_name || ' DISABLE CONSTRAINT ' || constraint_name || ';'
    from dba_constraints
    where owner = '<owner_name>';
    spool off;
    Hope that helps..

  • Primary keys and index

    Hi,
       I got these question in interview Plz answer them
       1. Maximum number of primary keys u can use for a table?
       2. Maximum number of indexes u can create?
       3. Maximum number of secondary indexes?
       4. Maximum number fields in a table?
       5. Maximum length of primary key field?
    Plz answer these questions
    regards,
    kumar

    >>1. Maximum number of primary keys u can use for a table?
    16
    >>2. Maximum number of indexes u can create?
    >>3. Maximum number of secondary indexes?
    Only 16 Primary Index and n number of secondary indexes.
    >>4. Maximum number fields in a table?
    249
    >>5. Maximum length of primary key field?
    255
    Cheers,
    Hakim
    Mark all useful answers..Close the thread once your question has been answered.

  • Display the foreign keys and primary keys in hirarchy qeury  please ?

    Any sql query to get the following columns:
    I should display all the master table names,it's primary key field and its foregin key field,the name of the foreignkey'table.
    This should be displayed in hirarchy i.e. it should start from the top level table like upside down tree.
    can we query the database like this
    thanx in advance
    prasanth a.s.

    hi there,
    Please can any body help in this query!
    Thanxs in advance
    prasanth a.s.

  • Ssis package error need help to fix it. though disabled all triggers and droped all the foreign keys and truncated tables on pipeline constraints.

    [PartyName1 [6672]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "Transaction (Process ID 1414) was deadlocked on lock resources with another process and has been chosen as the
    deadlock victim. Rerun the transaction.".

    you need to provide Details about your package like what is source/destination.. any SQL query/where is the exact deadlock point.
    Please check the following links which may help you.
    http://blogs.technet.com/b/fort_sql/archive/2011/12/12/get-rid-of-deadlocks.aspx
    http://msdn.microsoft.com/en-us/library/ms191242.aspx
    Let us TRY this |
    My Blog :: http://quest4gen.blogspot.com/

  • Questions about creating a foreign key on a large table

    Hello @ll,
    during a database update I lost a foreign key between two tables. The tables are called werteart and werteartarchiv_pt. Because of its size, werteartarchiv_pt is a partitioned table. The missing foreign key was a constraint on table werteartarchiv_pt referencing werteart.
    Some statistics about the sizes of the mentioned tables:
    werteart 22 MB
    werteartarchiv_pt 223 GB
    werteartarchiv_pt (Index) 243 GB
    I tried to create the foreign key again, but it failed with the following error (Excuses for the german error message):
    sqlplus ORA-00604: Fehler auf rekursiver SQL-Ebene 1
    sqlplus ORA-01652: Temp-Segment kann nicht um 128 in Tablespace TEMPS00 erweitert
    The statement I used:
    alter table werteartarchiv_pt
    add constraint werteartarchiv_pt_fk1
    foreign key (schiene, werteartadresse, merkmale)
    references werteart (schiene, werteartadresse, merkmale)
    on delete cascade
    initially deferred deferrable;
    So the problem seems to be, that Oracle needs a lot of temporary tablespace to generate the foreign key and I do not know how much and why.
    My questions now are, and hopefully someone is here, who can answer all or a part of it:
    1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.
    2a) Is it possible to tweak the statement without using the temporary tablespace?
    2b) If it is not possible to avoid the usage of the temporary tablespace, is there a formula how to calculate the needed temporary tablespace?
    3) Is it possible to modify data in the tables while the foreign key is created or is the whole table locked during the process?
    Any help or hint is appreciated.
    Regards,
    Bjoern

    RollinHand wrote:
    My questions now are, and hopefully someone is here, who can answer all or a part of it:
    1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.Because it's validating the data to ensure the foreign key won't be violated. If you had specified ENABLE NOVALIDATE when creating it then the existing data in the table wouldn't need to be checked and the statement should complete instantly (future data added would be checked by the constraint).
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/general005.htm
    Search for "Enable Novalidate Constraint State"

  • Primary key  ID ... Foreign key iD ???

    Here is the setup. I have a database on a SQL server and have
    created a form to input data into this database (with Dreamweaver
    and CF).
    Let me start out by telling you basically how this data base
    is setup:
    3 tables:
    - tblPatients (which is the main table). Primary key is ID
    (an auto number field).
    - tblDiagnosis (which only houses an ID field and code field
    called DSMIV). The ID in the tblDiagnosis table is a foreign key
    and is linked to the tblPatients table’s ID.
    -tlkpDiagnosis just house all the possible diagnosis.
    I am able to input data into both tblPatients table and the
    tblDiagnosis table, BUT the ID (foreign key) field in the
    tblDiagnosis table is left empty thus left orphaned with no way to
    tight it back to the data in the patient table. My code is below.
    Thank you for any help you can provide me.
    PROCESS PAGE CODE:
    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfif IsDefined("FORM.MM_InsertRecord") AND
    FORM.MM_InsertRecord EQ "form1">
    <cfquery datasource="dsnPsychiatry">
    INSERT INTO dbo.tblPatients (NewContinuous, ResidentID,
    ResidentInitial, Age, Race, Sex, EmploymentStatus, HP, MedCheck,
    Therapy30Minute, Therapy60Minute, TherapyGroup, ECT, Inpatient,
    Outpatient, EmergencyRoom)
    VALUES (
    <cfif IsDefined("FORM.NewContinuous") AND
    #FORM.NewContinuous# NEQ "">
    <cfqueryparam value="#FORM.NewContinuous#"
    cfsqltype="cf_sql_clob" maxlength="1">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.ResidentID") AND #FORM.ResidentID#
    NEQ "">
    <cfqueryparam value="#FORM.ResidentID#"
    cfsqltype="cf_sql_clob" maxlength="10">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.ResidentInitial") AND
    #FORM.ResidentInitial# NEQ "">
    <cfqueryparam value="#FORM.ResidentInitial#"
    cfsqltype="cf_sql_clob" maxlength="1">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.Age") AND #FORM.Age# NEQ "">
    <cfqueryparam value="#FORM.Age#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.Race") AND #FORM.Race# NEQ "">
    <cfqueryparam value="#FORM.Race#" cfsqltype="cf_sql_clob"
    maxlength="1">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.Sex") AND #FORM.Sex# NEQ "">
    <cfqueryparam value="#FORM.Sex#" cfsqltype="cf_sql_clob"
    maxlength="1">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.EmploymentStatus") AND
    #FORM.EmploymentStatus# NEQ "">
    <cfqueryparam value="#FORM.EmploymentStatus#"
    cfsqltype="cf_sql_clob" maxlength="10">
    <cfelse>
    </cfif>
    <cfif IsDefined("FORM.HP") AND #FORM.HP# NEQ "">
    <cfqueryparam value="#FORM.HP#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.MedCheck") AND #FORM.MedCheck# NEQ
    "">
    <cfqueryparam value="#FORM.MedCheck#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.Therapy30Minute") AND
    #FORM.Therapy30Minute# NEQ "">
    <cfqueryparam value="#FORM.Therapy30Minute#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.Therapy60Minute") AND
    #FORM.Therapy60Minute# NEQ "">
    <cfqueryparam value="#FORM.Therapy60Minute#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.TherapyGroup") AND
    #FORM.TherapyGroup# NEQ "">
    <cfqueryparam value="#FORM.TherapyGroup#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.ECT") AND #FORM.ECT# NEQ "">
    <cfqueryparam value="#FORM.ECT#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.Inpatient") AND #FORM.Inpatient#
    NEQ "">
    <cfqueryparam value="#FORM.Inpatient#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.Outpatient") AND #FORM.Outpatient#
    NEQ "">
    <cfqueryparam value="#FORM.Outpatient#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    <cfif IsDefined("FORM.EmergencyRoom") AND
    #FORM.EmergencyRoom# NEQ "">
    <cfqueryparam value="#FORM.EmergencyRoom#"
    cfsqltype="cf_sql_numeric">
    <cfelse>
    NULL
    </cfif>
    </cfquery>
    <cfloop list="#FORM.DSMIV#" index="diagnosis">
    <cfif IsDefined("FORM.DSMIV") AND #FORM.DSMIV# NEQ "">
    <cfquery datasource="dsnPsychiatry">
    INSERT INTO dbo.tblDiagnosis (DSMIV)
    VALUES (
    <cfqueryparam value="#diagnosis#" cfsqltype="cf_sql_clob"
    maxlength="50">
    </cfquery>
    </cfif>
    </cfloop>
    </cfif>

    Ok that didn't work. Most likely due to my lack of knowledge
    when it comes to this.
    I've been doing some research on Stored Prcedures, and
    thought it might be the answer to my problems.
    Here is the code I came up with.
    First is the Stored Procedure (on the SQL Server):
    CREATE PROCEDURE spInsertDiagnosis
    @ID integer,
    @DSMIV varchar(25)
    AS
    insert into tblDiagnosis (ID, DSMIV) values (@ID, @DSMIV)
    GO
    Second, is the CF on my process page
    <cfif IsDefined ("ID") AND #ID# NEQ "">
    <cfif IsDefined("FORM.DSMIV") AND #FORM.DSMIV# NEQ "">
    <CFSTOREDPROC procedure="dbo.spInsertDiagnosis"
    datasource="dsnPsychiatry">
    <CFPROCPARAM type="IN" dbvarname="@ID" value="#ID#"
    cfsqltype="CF_SQL_INTEGER">
    <CFPROCPARAM type="IN" dbvarname="@DSMIV" value="#DSMIV#"
    cfsqltype="CF_SQL_VARCHAR">
    </CFSTOREDPROC>
    </cfif>
    </cfif>
    NOTE: The above CF code replaced the below on my process page
    (ref to first post).
    <cfloop list="#FORM.DSMIV#" index="diagnosis">
    <cfif IsDefined("FORM.DSMIV") AND #FORM.DSMIV# NEQ "">
    <cfquery datasource="dsnPsychiatry">
    INSERT INTO dbo.tblDiagnosis (DSMIV)
    VALUES (
    <cfqueryparam value="#diagnosis#" cfsqltype="cf_sql_clob"
    maxlength="50">
    </cfquery>
    </cfif>
    </cfloop>
    PROBLEM now is, in doing this now nothing gets inserted into
    the Diagnosis table. Obviously I do not know how to correctly
    insert the stored procedure into my process page.

  • Move large tables and indexes into own tablespace

    I currently manage a 100Gb 10.2.0.4 SE database on Windows.
    There is one data tablespace and one indexes.
    I have one table xxxHistory that is periodically cleared out, however, six months of data must be retained.
    The table is currently 17Gb and has 95 million rows, the corresponding nine or so indexes take another 47Gb.
    I am having a small problem with I/O waits on this table so, I want to move this table and the indexes to their own tablespaces, which I will create (xxxHistory_D and xxxHistory_I).
    I know the two methods, exp/imp (difficult due to foreign keys) and the prefered method of :
    alter table tbl move tablespace tblsp and
    alter index ind rebuild tablespace tblsp.
    I have no problems with the syntax etc, having used this method many times.
    My question is, does anyone have a better idea of how to approach this to minimise downtime?
    The system cannot be used if this table is not available.
    I am also going to migrate to 11.2x when available but can't find anything in the new features to help.
    Note, this is SE, so partitioning is not an option and once I have sorted this table out, I will unchain the rows of any other and reorganise the space.
    Disk space is not an issue.
    Thanks,

    BigPhil wrote:
    Note, this is SE, so partitioning is not an option and once I have sorted this table out, I will unchain the rows of any other and reorganise the space.
    Disk space is not an issue.
    Strategically this sounds as if you really do need partitioning; since you're on SE, you could consider the v7 "partition view" concept.
    Create one table per month, and index each table separately.
    Add a constraint to each table of the form: "movement date between to_date('...') and to_date('...')"
    Create a union all view of the tables.
    Getting rid of a single month means redefining the view.
    In theory any queries you do should be able to filter predicate pushdown and thus eliminate redundant partitions, and also handle pushing joins down into the union all view. But that's something you would have to test carefully.
    You could even create the tables as index organized tables - which may be the solution to your I/O wait problems - if your queries are about stock movement then all the movements for a given stock will be thinly scattered across the table, leading to one block I/O per row required. IOTs would give you an overhead on inserts, but eliminate waits on queries.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Tracking down which unindexed foreign keys are the biggets problem

    I joined a new project recently. I checked prod and our biggest bottleneck is unindexed foreign keys. It is high enough that I can see that it is causing problems. So I ran a query and got a list of all the unindexed foreign keys. Unfortunately there are about 80 of them. This application was inherited. The last team lost the project and I think one of the issues is with an off the shelf application (which we can't get rid of).
    I really don't like the idea of adding 80 indexes in a big rollout. It is too big of a change to do at once. It is also hard to measure whether those indexes may cause other problems. So what I would like to do is take my Enqueue waits for unindexed foreign keys and somehow figure out which unindexed foreign keys are causing us the biggest problem. With this many there is a strong possibility that some of these tables are having their parents hit more than others and some of these tables are blocking other sessions more than others.
    any suggestions on how to do this? It doesn't need to be exact. However, Id like to propose adding indexes that will give us the biggest bang for the buck.
    I am not sure how to take my system wide enqueue/deque waits down to particular tables being hit with DML that cause locking on child tables that in turn cause other sessions to be blocked.

    Guess2 wrote:
    I am not sure how to take my system wide enqueue/deque waits down to particular tables being hit with DML that cause locking on child tables that in turn cause other sessions to be blocked.Depending on your version of Oracle, and whether or not you are licensed to run the performance pack and diagnostic pack, you could query v$active_session_history (and it's repository dba_hist_active_sess_history).
    The type of query you need would be something like:
    select
            blocking_session, current_obj#, substr(to_char(p1,'xxxxxxxx'),-1), count(*)
    from
            v$active_session_history
    where
            event like 'enq: TM - contention'
    and     session_state = 'WAITING'
    and     sample_time between sysdate - 1/24 and sysdate
    group by
            blocking_session, current_obj#, substr(to_char(p1,'xxxxxxxx'),-1)
    /The counts would give you relative time for blocking due to each "current_obj#" - which you'd have to look up against object_id.
    I've also broken this down by blocking_session_id, and the lock mode (which ought to be 4 or 5) - 4 would SUGGEST simple parent/child collisions, 5 would SUGGEST that the probem could be exacerbated by "on delete cascade" constraints.
    Regards
    Jonathan Lewis

Maybe you are looking for

  • Max characters in a Rich Text Editor?

    Is there a "hard limit" on the number of characters I can enter into a Rich Text Editor? My testing suggests that you can only have 4000 characters. If i submit more than 4000 i.e. 4001, I get the following error message: ORA-01461: can bind a LONG v

  • Premiere CC doesn't display/update windows sometimes in Windows 8

    Just recently, with Windows 8 and Premiere CC, I get a bug that makes Premiere unusable.  Certain windows don't draw or update regularly.  See attached screenshot (https://dl.dropboxusercontent.com/u/651378/premiere%20windows%20not%20showing.PNG).  N

  • Can´t create apps with CCP

    I get the following error when I try to create a new package in CCP 6/18/2013 13:27:26[INFO] AdobePackageBuilder - Build Version - 1.0.0.55 6/18/2013 13:27:26[INFO] AdobePackageBuilder - Logging Level verbosity Set  to 4 6/18/2013 13:27:27 [WARN] Ado

  • Spolight result and Applescript in harmony

    Hello, I'm new to Applescript and what I'm interested in doing seems like a great job for it. I've made a spotlight search on a single folder in the file system and saved the search to its default location (/Users/alex/Library/Saved Searches/searchQu

  • [SOLVED] Creating an invisible-to-the-outside network with Arch

    Hi All, I want to create an internal network to share access to a larger business network and to the outside world. Essentially, I want to create a small network that is invisible to the other machines and routers of our network, but which shares all