Optimize SQL queries run at startup on Oracle 12c

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Timed out
    • None
    • Component/s: None
    • None

      Problem Definition

      Users who have a large number of rows in the database have long load times when starting Bamboo. Part of the problem are the SQL scripts which check, and create constraints during startup.

      For example:

      SELECT NULL                                              AS pktable_cat ,
        p.owner                                                AS pktable_schem,
        p.table_name                                           AS pktable_name ,
        pc.column_name                                         AS pkcolumn_name,
        NULL                                                   AS fktable_cat ,
        f.owner                                                AS fktable_schem,
        f.table_name                                           AS fktable_name ,
        fc.column_name                                         AS fkcolumn_name,
        fc.position                                            AS key_seq ,
        NULL                                                   AS update_rule ,
        DECODE (f.delete_rule, 'CASCADE', 0, 'SET NULL', 2, 1) AS delete_rule ,
        f.constraint_name                                      AS fk_name ,
        p.constraint_name                                      AS pk_name ,
        DECODE(f.deferrable, 'DEFERRABLE',5 ,'NOT DEFERRABLE',7 , 'DEFERRED', 6 ) deferrabilityFROM all_cons_columns pc,
        all_constraints p ,
        all_cons_columns fc,
        all_constraints fWHERE 1 = 1
      AND f.table_name           = :2
      AND f.owner                = :4
      AND f.constraint_type      = 'R'
      AND p.owner                = f.r_owner
      AND p.constraint_name      = f.r_constraint_name
      AND p.constraint_type      = 'P'
      AND pc.owner               = p.owner
      AND pc.constraint_name     = p.constraint_name
      AND pc.table_name          = p.table_name
      AND fc.owner               = f.owner
      AND fc.constraint_name     = f.constraint_name
      AND fc.table_name          = f.table_name
      AND fc.position            = pc.positionORDER BY pktable_schem,
        pktable_name ,
        key_seq
      

      Queries against ALL_CONSTRAINTS take longer due to changes in the view definition of ALL_CONSTRAINTS in Oracle 12.1.0.2 – DOC_ID 2266016.1

      Suggested Solution

      Alter one of the following Session Parameters to improve performance (but not all three)

      ALTER SESSION SET "_optimizer_push_pred_cost_based" = FALSE;
      
      ALTER SESSION SET "_optimizer_squ_bottomup" = FALSE;
      
      ALTER SESSION SET "_optimizer_cost_based_transformation" = 'OFF';
      

      Workaround

      wait 4-10 minutes for Bamboo to start

            Assignee:
            Unassigned
            Reporter:
            Robert W (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: