Select the query takes a long time to run the second time

Hi all

I have Oracle 11 GR 1 material in windows server 2008 R2.
I have a few tables with 10 million documents. When I run the select query to the tables of first time, it gives me a result in 15 seconds, but if I run the script even twice in the same session, I get the result in 15 minutes to complete...

Why it's happening? What can be the solution for this?

Thank you and best regards,
Vikash jain (DBA Junior)

What I know is that this feedback from cardinality generates more problems than improving the performance is, in fact, its main objective. But first look at which is was written in the link I posted above

"Return of cardinality was introduced in the Oracle 11 g database 2. The purpose of this function is to automatically improve plans for queries that are executed repeatedly, _For that the optimizer does not estimate the cardinalities in the properly_ plan"

If the cardinality feedback kiks in your case it is certainly because you do not have an exact statistics. Get the command the explain plans that I have shown you with the E-lines and A-lines (lines estimates and actual lines) and see where things are poorly estimated.

If you want to disable the cardinality feedback then add the indicator according to your request

/*+ opt_param('_optimizer_use_feedback','false') */

Best regards

Mohamed Houri
www.hourim.WordPress.com

Published by: Mohamed Houri on November 22, 2012 02:11
Published by: I was looking for the exact indication of how do I deactivate the cardinality feedback and I foud in an ot the Dominic post in otn :-)

Published by: Mohamed Houri on November 22, 2012 02:15

Tags: Database

Similar Questions

  • Query takes a long time

    Hi Experts

    I'm using Oracle 11 g, I use under delete query to remove records of staging table.

    under query takes a long time (ranging from 1 hour, even there is no record to delete.

    I created payment_id indexes also did not help.

    delete from siebelwb.stg_p where payment_id not in (select * from siebel.s_src_payment)

    I know NOT of IN is degreding performace, is there another way to write above request so that we can remove them in NOT IN use.

    Try to use NOT EXISTS clause...

    Also you inner query must match the payment_id with query parent then here's the example query...

    removal of siebelwb.stg_p where THERE is NO payment_id (select 1 from siebel.s_src_payment where s_src_payment.payment_id = stg_p.payment_id)

  • DELETE the query takes a long time

    Hi all guru.

    My Version of DB: 10.2.0
    OS: Windows Server 2003

    I run a delete on a table of paritioned command to remove all the lines in one of the parition. The command is:

    The table name is cat_in_data_052012

    delete CAT_IN_DATA_052012 WHERE name of FILE AS: SYS_B_O


    Table conatins million record.


    Thanks in advance

    >
    I run a delete on a table of paritioned command to remove all the lines in one of the parition. The command is:

    The table name is cat_in_data_052012

    delete CAT_IN_DATA_052012 WHERE name of FILE AS: SYS_B_O
    >
    Mention the name of partition specifically in the query to ensure that only one partition is affected.

    See the example (at the end) for the deletion of rows in a Partition in the SQL reference Guide
    http://docs.Oracle.com/CD/B12037_01/server.101/b10759/statements_8005.htm#i2126857

    Deleting Rows from a Partition: Example
    
    The following example removes rows from partition sales_q1_1998 of the sh.sales table:
    
    DELETE FROM sales PARTITION (sales_q1_1998)
       WHERE amount_sold > 10000;
    
  • Create table as select statement (ETG) takes a long time.

    Hi all

    One of my procedure launched a table create as select statement each month.
    Usually it ends in 20 minutes. for 6172063 records and 1 hour in 13699067.
    But this time it never even takes to 38076 records.
    When I checked everything he does is the CPU usage. No e/s.
    I did a count (*) using the query, it has brought very good results.
    BUT guard going on DEC.
    I use Oracle 10.2.0.4.
    temp_ip of the main table has 38076
    table nhs_opcs_hier has 26769 records.
    and table nhs_icd10_hier 49551 records.
    -------------------
    Query is:
    create the table analytic_hes.temp_ip_hier as
    Select b.*, (select nvl (max (hierarchy), 0))
    of ref_hd.nhs_opcs_hier one
    where fiscal_year = b.hd_spell_fiscal_year
    and a.code in
    (primary_PROCEDURE, secondary_procedure_1, secondary_procedure_2,
    secondary_procedure_3, secondary_procedure_4, secondary_procedure_5,
    secondary_procedure_6, secondary_procedure_7, secondary_procedure_8,
    secondary_procedure_9, secondary_procedure_10,
    secondary_procedure_11, secondary_procedure_12)) as hd_procedure_hierarchy,
    (select nvl (max (hierarchy), 0) for ref_hd.nhs_icd10_hier one)
    where fiscal_year = b.hd_spell_fiscal_year
    and a.code in
    (primary_diagnosis, secondary_diagnosis_1,
    secondary_diagnosis_2, secondary_diagnosis_3,
    secondary_diagnosis_4, secondary_diagnosis_5,
    secondary_diagnosis_6, secondary_diagnosis_7,
    secondary_diagnosis_8, secondary_diagnosis_9,
    secondary_diagnosis_10, secondary_diagnosis_11,
    secondary_diagnosis_12, secondary_diagnosis_13,
    secondary_diagnosis_14)) as hd_diagnosis_hierarchy
    of analytic_hes.temp_ip b
    -----------------

    Any help would be greatly appreciated

    Hello

    It is a bit of a wild card, I think because it will require 14 scans to fill the table temp_ip to unpivot codes diagnostic and procedure, so this lilkely things are moving slower than the original. However, as it is a temporary table, I guess you could have some control over its structure, or at least be able to dismiss it and try something else. If you are able to change the structure of this table, you could make the application much simpler and probably much faster. I think that you need a list of codes of procedure for the year and a list of diagnosis for fiscal codes. I do this through the large list of UNION all THE INSTRUCTIONS, but you can have a more efficient way to do according to the base tables you are people temp_ip of. In any case, it's here (as far as I can tell this will do the same job)

    WITH codes AS
    (   SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            primary_PROCEDURE       procedure_code,
            primary_diagnosis       diagnosis_code,
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_1    procedure_code,
            secondary_diagnosis_1    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_2    procedure_code ,
            secondary_diagnosis_2    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_3    procedure_code,
            secondary_diagnosis_3    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_4    procedure_code,
            secondary_diagnosis_4    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_5    procedure_code,
            secondary_diagnosis_5    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_6    procedure_code,
            secondary_diagnosis_6    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_7    procedure_code,
            secondary_diagnosis_7    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_8    procedure_code,
            secondary_diagnosis_8    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_9    procedure_code,
            secondary_diagnosis_9    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_10  procedure_code,
            secondary_diagnosis_10    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_11  procedure_code,
            secondary_diagnosis_11    diagnosis_code
        FROM
            temp_ip
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_12  procedure_code,
            secondary_diagnosis_12    diagnosis_code
        FROM
            temp_ip
    ), hd_procedure_hierarchy AS
    (   SELECT
            NVL (MAX (a.hierarchy), 0) hd_procedure_hierarchy,
            a.fiscal_year
        FROM
            ref_hd.nhs_opcs_hier a,
            codes pc
        WHERE
            a.fiscal_year = pc.hd_spell_fiscal_year
        AND
            a.code = pc.procedure_code
        GROUP BY
            a.fiscal_year
    ),hd_diagnosis_hierarchy AS
    (   SELECT
            NVL (MAX (a.hierarchy), 0) hd_diagnosis_hierarchy,
            a.fiscal_year
        FROM
            ref_hd.nhs_icd10_hier a,
            codes pc
        WHERE
            a.fiscal_year = pc.hd_spell_fiscal_year
        AND
            a.code = pc.diagnosis_code
        GROUP BY
            a.fiscal_year
    )
    SELECT b.*, a.hd_procedure_hierarchy, c.hd_diagnosis_hierarchy
      FROM analytic_hes.temp_ip b,
           LEFT OUTER JOIN hd_procedure_hierarchy a
              ON (a.fiscal_year = b.hd_spell_fiscal_year)
           LEFT OUTER JOIN hd_diagnosis_hierarchy c
              ON (c.fiscal_year = b.hd_spell_fiscal_year)
    

    HTH

    David

  • SQL query takes too long to run (1 h 25 min)... pls help how to set up the query.

    Hello

    Could someone please help how to tune the query as its takes a long time to retrieve the results.

    Select

    col1,

    col2,

    col3,

    COL4,

    col5,

    col6,

    col7,

    COL8,

    col9,

    col10,

    Col11,

    col12,

    Sum (volume1),

    Sum (volume2),

    Sum (volume3),

    Sum (volume4),

    Sum (volume5),

    Sum (volume6),

    Sum (volume7),

    Sum (volume8),

    Sum (volume9),

    Sum (volume10),

    Sum (volume11),

    Sum (volume12),

    Sum (volume13),

    Sum (volume14),

    Sum (volume15),

    Sum (volume16),

    Sum (volume17),

    Sum (Volume18),

    Sum (volume19),

    Sum (volume20),

    Sum (rate1),

    Sum (rate2),

    Sum (rate3),

    Sum (rate4),

    Sum (rate5),

    Sum (rate6),

    Sum (rate7),

    Sum (rate8),

    Sum (rate9),

    Sum (rate10),

    Sum (rate11),

    Sum (rate12),

    Sum (rate13),

    Sum (rate14),

    Sum (rate15),

    Sum (rate16),

    Sum (rate17),

    Sum (rate18)

    Sum (rate19),

    Sum (rate20)

    Of

    Table 1 - 13, 25, 99, 400 records

    Table2 - 13, 45, 1000 records

    Table 3 - 4, 50, 000 records

    Table 4 - 1,00,000 records

    table5 - 30 000 records

    where tabl1.col1 = table2.col2,

    Table1.Col1 = table3.col1.

    table2.col2 = table3.col2...

    Group

    Sum (volume1),

    Sum (volume2),

    Sum (volume3),

    Sum (volume4),

    Sum (volume5),

    Sum (volume6),

    Sum (volume7),

    Sum (volume8),

    Sum (volume9),

    Sum (volume10),

    Sum (volume11),

    Sum (volume12),

    Sum (volume13),

    Sum (volume14),

    Sum (volume15),

    Sum (volume16),

    Sum (volume17),

    Sum (Volume18),

    Sum (volume19),

    Sum (volume20),

    Sum (rate1),

    Sum (rate2),

    Sum (rate3),

    Sum (rate4),

    Sum (rate5),

    Sum (rate6),

    Sum (rate7),

    Sum (rate8),

    Sum (rate9),

    Sum (rate10),

    Sum (rate11),

    Sum (rate12),

    Sum (rate13),

    Sum (rate14),

    Sum (rate15),

    Sum (rate16),

    Sum (rate17),

    Sum (rate18)

    Sum (rate19),

    Sum (rate20)

    Thank you

    Prasad.

    > Could someone please help how to tune the query as its takes a long time to retrieve the results.

    The query you posted is obviously fake.

    If you ask to give us a request that you do not post and we cannot see.

    For real?

  • All while saving the have drop its takes a long time

    I am using windows 7 and have CC, when I'm working on files while saving the file have its takes a long time. I have 4 GB of RAM. now I'm better system too with 6 GB ram. stillthe HERE takes a long time to save the 300 MB file.

    It could be where you register to.  Make sure that you set up a database on your local drive (that is, your computer's hard drive).  Then select your disks scratch in the preferences (make sure you have enough free space and there is enough defragmented).  Backup speed is not a problem of RAM.  Make sure that you save not on a network drive. People have also disabled 'save with PDF compatibility' > OFF in the preferences help to accelerate.

  • How to get rid of the msg "...". is very large and may take a long time to

    Hello
    Simple question:
    How to get rid of msg "...". is very large and might take a long time to load... »
    I tried to increase the number of cells under "App settings-> options-> warn if greater than 5 000 000 000 data form. I even tried to '0 '. Nothing works planning 9.3.1

    Hello

    That's how I've always changed the number of cells, after which display the message on the forms of data.

    There are 2 levels of adjustment. You can configure the application level, but users must select "Use Application Defaults" in the planning of the preferences of the user parameters. To do this, use the file-> Preferences and select schedule.

    Otherwise, you can set the value of the number of cells at the level of the user for ' warn if data form more xxxx ". It should solve the problem. This should be the installation program if you have not selected checkbox default Application for the user in the preferences of planning.

    If nothing else works, it is very difficult to guess, I would open a SR with Oracle.

    Let me know if it helps.

    See you soon
    RS

  • The system preference takes a long time to load

    As the title suggests, end of 2013 (10.11.4) System Preferences on my iMac takes a long time to load, even after a fresh reinstall and/or reboot (tried both). It takes about 20 seconds to one minute each time to open (except when I close it and immediately open it once again, as it is always loaded in memory). This problem existed only after the upgrade to El Capitan, and I saw many other people with iMacs with the same problem. I tried to remove cache for before system preferences files, but that did not help at all. I don't have a FileVault if it makes a difference, even if I did before reinstall, but never turned back (persistent question anyway). Any recommendations would be useful. Thank you!

    Data sheet:

    iMac (end 2013)

    Intel Core i5 at 2.7 GHz

    8 GB 1600 MHz DDR3

    1 TB 5400 RPM HARD DRIVE

    Intel Pro Iris 1536 MB

    I found it is the State of affairs in 10.11 if running a HD spinning.  Don't feel alone.

    I suspect that it is a function of low priority in the memory compressed algorithm.

    Upgrading to an SSD and it will rise to attention.

  • Visual Studio 2008 Pro takes a long time to start after the installation of measurement Studio 2009

    After installing Measurement Studio 2009, I noticed that it takes a long time (30-60 seconds) to open a Visual Studio project.

    I do not have an internet connection on my development computer and suspect he might be waiting on some kind of operation of the network to time out.  I had problems with Visual Studio in the past as well and had to work around them by adding entries to my hosts file (to redirect some addresses of Microsoft to the local IP address - this causes network operations to expire immediately).

    Just curious if anyone has encountered this kind of slow startup time and found a solution.

    Thank you!

    I found an article referring to a question similar to MS 8.1.  I don't know if the problem has simply not been corrected or why I am still having this problem.  Workaround "per computer" listed in the article solved my problem.

    http://digital.NI.com/public.nsf/allkb/18E25101F0839C6286256F960061B282 I have

  • How can I stop my computer to go to the screen saver when I for example runs a scan of the computer, sometimes my scan takes a long time to finish?

    My problem is? How can I stop my computer to go to the screen saver when I for example runs a scan of the computer, sometimes my scan takes a long time to finish? Example I have Microsoft Security Essentials set allow to run daily on 1200 AM and until he finishes my computer goes to screen saver Mode. and when I click on my mouse, I must sign completely new in my computer > how to stop this from happening, I want to keep my Security Scan open until there finishes?

    All the solutions for this?

    Original title: Windows Vista systems

    Hello

    This can help you:

    "Enable or disable the screen saver.

    http://Windows.Microsoft.com/en-us/Windows/turn-screen-saver-on-off#1TC=Windows-Vista

    And this is how do to change the time to wait before the screensaver comes on (article 8) and how to disable the password to logon to him (art. 9):

    http://www.Vistax64.com/tutorials/85539-screen-saver.html

    "How to disable or enable Protection by password on Wake Up in Vista"

    http://www.Vistax64.com/tutorials/102686-password-protection-wakeup.html

    See you soon.

  • Z10 Z10 Blackberry BlackBerry takes a long time to start when the parameters "SIM card PIN lock" is activated

    Device: BlackBerry Z10
    Model: STL100-1
    Software version: 10.2.1.537
    OS version: 10.2.1.1925
    Carrier: Beeline (KZ)

    Z10 takes a long time to start when the parameters 'SIM card PIN lock' is running

    Tried to activate or disable this setting, the result:

    On - 5 min 13 sec (on-screen progress bar has reached 100% for ~ 1 minute, then waited for another 4 minutes in this State)

    Off - 1 min 17 sec

    What is the problem of the time difference?

    Good, thanks

  • After that effects 2015.3 takes a long time to open, left after the closing process running

    My AE 2015.3 takes very long time to start. He gets the message "Initializing MediaCore" on the splash screen and then hangs there for 1-3 minutes. It opens also a ton of "Adobe After Effects 2015.3" tasks in the Task Manager, leaving them running even after I quit the program.

    Here is what my task manager looks at this time (no AE running)

    AECrazy.jpg

    So far, what I've done:

    1 uninstalled all Adobe software, including Adobe CC Panel

    2 uninstalled all 3rd party plugins, scripts, and presets

    3. manually deleted all files from adobe - complete cleaning

    4. re-installed AE and some other programs

    (all with reboot between the two).

    No difference.

    Help?

    Apparently, nVidia GeForce drivers are at fault. The break of v368.81 WHQL way Adobe applications communicate with Media Core, make After Effects, first and slow speed Grade, leaving the additional processes in their wake and spoil some plugins 3rd party.

    Returning to a previous driver nVidia solved all the problems.

  • Still burned DVD takes a long time to load into the reader

    I created a DVD in Encore CS3.  The final DVD is approximately 60 minutes and has 4 menus created in Photoshop CS3.  I purchased the Dolby converted in first and used this file as PCM format indicated by a friend vs.   The DVD works fine but takes a long time to load in one of my DVD players.

    A Sony player, it takes between 40 minutes and up to 70 seconds to load and play the first menu.  Each time is different.

    (This same drive load purchased in-store Hollywood style DVD in about 15 seconds on average)

    In another Sony player my DVD on average about 25 seconds

    A Panasonic player, it takes about 15 seconds

    In a portable player from JVC, it takes about 8 seconds.

    That is what it is?  This DVD is created for replication in a large number, but I'm afraid the long loading time is a problem and you want to solve this problem before sending it to the wide for replication.

    Help, please

    Thank you

    EDM

    EDM,

    One consideration is that there is no DVD drive certified to play any burned DVD, only those press/replicated. Most do and do as well, with provisions, but some don't.

    Now for these provisions. High quality blank media will get a closer all the success, just like using a slower speed of the burn, as the max. These two considerations will get a close, as it is possible.

    What brand of blank media are you using? Verbatim and Taiyo Yuden are about as good as it gets.

    How fast you burn to? I would look into a speed in the middle of the range permitted by the combo of speed by the media and the burning speed. Slower is better than more fast.

    As Stanley, there may be differences with r and + R media and players. There has been much more a problem, but some players still might prefer a vs the other.

    Finally, when you say "replicated", do you mean that you send in a DLT to make a House of replication a glassmaster, where the DVD is going to be in a hurry? If Yes, these replicated discs will be like the Hollywood DVD and will be NOT burnt, as was your test drive. The question will be moot with these, as they will be DVD-videos, where your burned DVD is really a DVD - ROM.

    Good luck

    Hunt

  • Starting the server takes a long time due to the storage of JMS persistence files

    Hello

    We use WebLogic 9.2 on a windows machine.
    Recently, we have improved our request to work with JMS.
    We are on 2 different servers in a cluster using 2 JMS servers and works with distributed destinations.
    We use file storage as our persistence store.

    Recently, we found boot server takes a long time because of the actions that are performed on the storage of files.
    Analysis of this problem, we have seen that the size of the file is of ~ 2 GB.
    We understand that the file size does not fear (unless it is compacted manually), and its size matches the largest number ever of pending messages in the queues (as a mark of high tide).
    We shot also store debugging, using weblogic. Debug.DebugStoreIOPhysical and we saw a lot of recovery after newspapers file storage is open.
    We have checked and checked our JMS transactions are completed successfully. We also checked that the current messages and number of courses is 0.
    We stopped the server gracefully, check that there are no messages pending.
    However, several times takes start server ~ 30 minutes due to heavy work on the persistence store.
    Compaction or remove storage of files eliminates the delay.
    However, we want to avoid the manual operations whenever we want to start the server.

    Please share your ideas.

    Thank you
    Itsik

    The only suggestions I have off the top of my head are:

    * Ensure (1) the host system has at least 2 GB (the store file size) memory physics in addition to the memory used by the current process, and (2) the host system is not rebooted between each restart WebLogic. If you ensure that both of these, then the operating system puts implicitly cached content of the file of the store in memory even between boots - when WebLogic starts subsequently storing files, the o/s should be the content of the file much more quickly.

    * You can move to a JDBC store. Runtime JDBC store performance are lower, but since you have generally has only a small amount of records to retrieve, startup performance should be higher in this case.

    * Not that it helps your case, but it happens that we have significant performance improvements of starting process for a future version (if all goes well a near future release).

    Tom

  • APEX_UTIL & APEX_INSTANCE_ADMIN take a long time to display the results in the browser

    Hi gurus of the APEX.
    When I create a new workspace with and add a new user with the API
    It takes a long time until I can see the results in the admin interface apex I NTHE browser.
    Why is this?
    Someone can explain or do you have a work around to make it faster?


    Here is the code I use:

    BEGIN
    APEX_INSTANCE_ADMIN. ADD_WORKSPACE(1196509005817318,'WORKSHOP','HR',)
    wwv_flow_api.set_security_group_id('1196509005817318');
    APEX_UTIL. CREATE_USER)
    p_user_name = > 'MY_ADMIN ',.
    p_first_name = > "FRANK."
    p_last_name = > 'SMITH ',.
    p_description = > "Description...". »,
    p_email_address = > '[email protected] ',.
    p_web_password = > 'oracle ',.
    p_developer_privs = > ' ADMIN: CREATE: DATA_LOADER:EDIT:HELP:MONITOR:SQL',.
    p_default_schema = > 'HR ',.
    p_allow_access_to_schemas = > 'OEHR. "
    p_change_password_on_first_use = > 'n',.
    p_attribute_01 = > ' 123 456 7890');
    END;
    /


    Thanks in advance.
    BR,
    Lutz

    Hi Lutz,

    I'm going to ask the obvious question, please do not be offended ;)

    You remember to "commit" the end of it if you run via SQLPlus etc.?

    John.
    --------------------------------------------
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    AWARDS: Don't forget to mark correct or useful posts on the forum, not only for my answers, but for everyone!

Maybe you are looking for