简体   繁体   中英

How I can optimize slow query in oracle

INSERT INTO temp_cl_user_pks
    SELECT DISTINCT
      tb_abc_login.pk_tb_login_master login_master, --Modified for Pega_S-121214-007856 (Defect #7551)
      tb_user_details.email_id        email
    FROM tb_abc_login            tb_abc_login,
         tb_user_details         tb_user_details,
         tb_unit                 tb_unit,
         tb_user_hierarchy       tb_user_hierarchy,
         tb_company_lmn          tb_company_lmn,
         tb_user_company         tb_user_company,
         temp_cl_units_hierarchy aa
    WHERE tb_unit.processor_key                   LIKE aa.cl_region_key

      AND tb_abc_login.pk_tb_abc_login          = tb_user_details.fk_tb_abc_login
      AND tb_abc_login.rec_status               = 'AC'

      AND tb_user_value.rec_status              = 'AC'

      AND tb_unit.unit_id                       = tb_user_hierarchy.fk_unit_id
      AND tb_unit.purgeid                         IS NULL

      AND tb_user_hierarchy.fk_tb_abc_login     = tb_abc_login.pk_tb_abc_login
      AND tb_user_hierarchy.rec_status          = 'AC'

      AND tb_user_company.fk_tb_company_lmn     = tb_company_lmn.pk_tb_company_lmn
      AND tb_user_company.fk_tb_abc_login       = tb_abc_login.pk_tb_abc_login
      AND tb_user_company.rec_status            = 'AC'

      AND tb_company_lmn.rec_status             = 'AC'
      AND UPPER(tb_user_value.email_id)           LIKE email ESCAPE '\'
      AND tb_company_lmn.pk_tb_company_lmn      = aa.fk_tb_ref_hierarchy
      AND tb_user_hierarchy.fk_tb_ref_hierarchy = tb_company_lmn.pk_tb_company_lmn
      AND tb_unit.restricted_flag               ='Y'
        --AND  tb_user_company.secure_hierarchy ='Y'
      AND aa.region_short_code                  ='LMN';

There is no silver bullet solution to query optimization and performance tuning on a RDBMS database.

There are countless articles on this topic. There are a few places where you could start digging to find out the root cause.

1) Check system resources. Does your system have adqeuate resources at its disposal?

2) Check if the system is correctly configured.

3) Look at the explain plan for the query.

If your issue is not located by steps 1 or 2. Then you need to dig deeper into the explain plan. If you edit your question and post your explain plan, others might be able to help you further.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM