Unexpected SQL execution timing

Oracle Version 9i
Win 2000/XP
We have one table comm which is a huge partitioned table (range - quarter). We had one time-taking statement that we were trying to tune -
DELETE FROM comm WHERE paid <> 'Y';
The explain plan told us that the index was not getting hit (which is understandable). The cost was around 270K odd.
We changed the statement to delete a similar numer of records -
DELETE FROM comm WHERE paid = 'N';
DELETE FROM comm WHERE paid = 'X';
DELETE FROM comm WHERE paid = 'ZZ';
This time the index was getting hit but the cost was still around 260K odd. However, the time taken to execute the 3 given statements went down from 40-minutes to 1minute!
What I am not able to understand is how come the Cost was so way off in estimation. Thanks in advance for your responses.
Additional info - the 3 statements will always use the latest partition only. However, the explain plan shows that it traverses all the partitions in both the scenarios.

The query itself does not hit a specific partition - you said that the PAID column is a local partitioned index. This means that the DELETE predicate does not allow for partition pruning - only hitting specific partitions.
So depending on the volume of data to process, this can be very slow. Which is the next point. The way the predicate is constructed. A "PAID <> value" is very different than "PAID = value1 OR PAID = value2". The first requires an index range scan (if the index can be used optimally) to determine which rows have indexed values that are not equal to the stated value.
Range scans can be problem - the bigger the range, the more I/O is needed. I/O is the slowest and most expensive of all RDBMS operations.
Compare this to telling the CBO the value of PAID that you're looking for - the ideal way an index should be used.
As for the CBO costs - ignore it. Comparing the cost of one query with that of another query (or even similar query) is not a sensible thing to do. To read up what experts say on it, go to http://asktom.oracle.com and do a search on "comparing cbo costs" or something along those lines. Lots of interesting stuff there.
Is PAID index a bitmap index? Or a standard B+tree index?

Similar Messages

  • Possible to get SQL execution timing?

    Is it possible to get wall-clock timing information in thesame way as using "set timing on" in SQL*Plus?

    I think the information you need is automatically displayed on the toolbar of the Sql Worksheet, to the right of the 'execute explain plan (F6)' and 'Clear (Ctrl-D)' buttons.

  • Error during SQL execution

    Hi Experts,
    We run a report which fails frequently with the below error. Could any one help me with the solution and reasons for this error.
    Error during SQL execution: (DA0003): [Exception: DBD, ORA-01722: invalid number State: N/A] The following data providers have not been successfully refreshed: His. (DMA0007): []
    Connection or SQL sentence error: (DA0005): [Exception: DBD, ORA-12535: TNS:operation timed out State: N/A] A connection required to refresh this document is unavailable. (DA0004): [] The following data providers have not been successfully refreshed: Reservations CW. (DMA0007): []
    Many Thanks
    Regards,
    Syed

    Hi,
    The report is running for long time and it's getting failed. could you please let me know what could be the reason for this?
    And could you please tell me the reason/Solution for the first error which i mentioned before.
    Many Thanks
    Regards,
    Syed

  • SSIS 2012 Scheduled SSIS package fail to start – Execution timed out

    Hi
    I am currently running into an issue that seem to have a live Connect issue raised for it. The following is the link to the connect issue https://connect.microsoft.com/SQLServer/feedback/details/783291/ssis-package-fails-to-start-application-lock-timeout-in-ssisdb-catalog-create-execution
    There is also a blog post that explains this issue in more detail, however the solution
    it provides does not work all the time and I am very reluctant to create custom stored procedures in the SSISDB. http://speaksql.wordpress.com/2013/06/27/ssis-2012-fail-to-start-execution-timed-out/
    Just to give some more background. When scheduling 10 or more, in my case I scheduled 14, SQL Server Agent Jobs all executing a package in the SSIS Catalog and all kicking off on exactly the same time about 10% to 20% of these jobs fail stating one of the
    following error messages:
    The operation failed because the execution timed out.  Source: .Net SqlClient Data Provider  Started:  12:20:01  Finished: 12:20:07  Elapsed:  5.797 seconds.  The package execution failed.  The step failed.
    Description: Transaction (Process ID 66) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.  Source: .Net SqlClient Data Provider  Started:  14:06:48  Finished: 14:06:53
     Elapsed:  4.719 seconds.  The package execution failed.  The step failed.
    This timeout takes place both when using TSQL to start the package in the Job or when the step in the Job is set to start the package as an Integration Services Package.
    Steps to recreate this:
    1. Create one SSIS package that simply executes for around a minute. For example you can use an Execute SQL Task and simply execute the following TSQL "WAITFOR DELAY '00:01:00'"
    2. Create 14 SQL Server Agent Jobs each executing the same package and schedule all of them to run at the same time.
    3. Watch the execution of the jobs take place and note the failures. (This does not always happen and you might get one run in which everything executes without a problem. The next run might have 6 or 7 of the jobs fail.)
    You can also create 14 different SSIS packages, one for each job, and the result is the same.
    I am running on SQL 2012 SP1 CU4. Windows Server 2012 R2 patched to the lastest patch level.
    This issue does not happen when the packages are deployed to the SSIS Package Store the way that it was done in SQL2008 and before. It only occurs when the SSIS packages are deployed to the SSIS Catalog.
    Any help or feedback on this would be greatly appreciated.
    Kind Regards,
    Christo Olivier

    Hi Tom
    Thank you for the fast response. I went and increased the value by 1024KB instead of the initial
    512KB. Unfortunately this seems to only alleviate the issue but does not stop it from occurring. It
    is happening much less often now but still occurring intermittently.
    Regards,
    Christo

  • SQL execution error, ORA-01843: not a valid month

    Im using ASP/VBScript and its my first time starting to use Oracle as a DB provider.
    Just having an issue with a statement that I have.
    Heres my statement:
    SELECT T592_NOON.SHIP_CODE, T592_NOON.REPORT_DATE, T592_NOON.L_B, T592_NOON.AVERAGE_SPEED, T592_NOON.SEASTATE, T592_NOON.DISTANCE, T592_NOON.WIND_DIRECTION, T592_NOON.IFO_MAIN, T592_NOON.IFO_BOILER, T592_NOON.IFO_AUXENGINE FROM T592_NOON WHERE (((SHIP_CODE)='S271') AND (REPORT_DATE BETWEEN to_date('08/02/2004 13:00:00', 'DD-MON-YYYY HH24:MI') and to_date('28/02/2004 18:15:00', 'DD-MON-YYYY HH24:MI')))
    Whenever I run it it errors and returns:
    SQL execution error, ORA-01843: not a valid month
    Can anyone tell why this wouldnt work?
    REPORT_DATE type is DATE
    REPORT_DATE Sample data: 2003-04-28-12.00.00.000000

    Changing the format of the date seemed to fix it.
    Incorrect: '08/02/2004 13:00:00'
    Correct: '08-FEB-2004 13:00'

  • Error Executing Database Query.coldfusion.sql.DatabaseConnectionException: Timed out trying to establish connection

    My coldfusion service crashes intermitantly and when I check
    the application logs the error that I see for the time frame is the
    one below. Does anyone know where I might begain to solve this?
    Thanks!
    Error Executing Database
    Query.coldfusion.sql.DatabaseConnectionException: Timed out trying
    to establish connection The specific sequence of files included or
    processed is: E:\wwwroot\lifeworks\default.cfm

    I'm no expert, but thought I would try to be helpful.
    I was getting this same error on a regular basis.
    The short term fix was to restart the ODBC server service.
    The long term fix was twofold:
    1. I recreated the ODBC connection in ColdFusion
    Administrator to use the system connection (I was using the SA and
    PW for login).
    2. I created a second user ODBC connection as well as the
    system one under ODBC in Windows Server 2003.
    I haven't had the problem since.
    I also read a pretty good set of "stuff" to try from the help
    area:
    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_17277
    Hope this helps.

  • OEM 11g - Monitored SQL Executions, click SQL ID, shows blank screen??

    I am trying to investigate my execution plans against my DB; and was informed i can check current status of SQL scripts using:
    Performance tab > SQL Monitoring > Monitored SQL Executions
    I click on SQL ID i want to investigate and comes back with blank screen instead of the overview tab.
    See Oracle URL below for screenshot
    Figure 6-8 Monitored SQL Execution Details Page
    http://download.oracle.com/docs/cd/E11857_01/em.111/e11982/database_management.htm
    Kind Regards,
    Paul

    Please log an SR provide SQL Monitor Active Report for your SQL. Thanks.
    -Mughees

  • Backtrace of ABAP and SQL execution

    Hello everyone!
    Does anybody know how to see logs of ABAP and SQL execution. I saw SLG1 but didn't found this information.
    I'm not interested in writing to SLG, I want to have opportunity to see the User, who deleted some entries from tables or launched ABAP code, for example.

      Do you mean transcation SCU3 for viewing table changes?
    Yes
    About ABAP-SQL execution... I can't foresee which program will be executed and which table will be effected, so I need some report that shows for particular table which statement was executed, and report about list of programs run by user. Do you know this?
    You can see which transaction is executed by a user on given period of time by using transaction ST03
    But which table accessed or which sql executed, in a scenrio in which you cannot forsee then its not possible.

  • Question on Dynamic SQL Execution

    Hi,
    Our company is currently using Oracle 7 but will move to Oracle 8i soon. I am trying to execute a dynamic SQL statement in a function and it always error-out during execution. The SQL statement is NOT doing any update to a table. Its doing a select only. The function is being called during an execution of another dynamic SQL statement in a procedure. Here are examples of the code listing for the procedure and function:
    CREATE OR REPLACE PROCEDURE TEST_PROC
    lookup_cursor      integer;
    ignore          integer;
    VARvalue          number;
    begin
    lookup_cursor := DBMS_SQL.open_cursor;
    DBMS_SQL.PARSE( lookup_cursor,
              'SELECT ' || TEST_FUNCTION || ' FROM DUAL,
              DBMS_SQL.NATIVE);
    DBMS_SQL.DEFINE_COLUMN( lookup_cursor, 1, VARvalue);
    ignore := DBMS_SQL.EXECUTE(lookup_cursor);
    loop
         IF DBMS_SQL.FETCH_ROWS(lookup_cursor) > 0 THEN
         DBMS_SQL.COLUMN_VALUE(lookup_cursor, 1, VARvalue);
         ELSE
         EXIT;
         END IF;
    END LOOP;
    DBMS_SQL.CLOSE_CURSOR(lookup_cursor);
    end TEST_PROC;
    CREATE OR REPLACE PROCEDURE TEST_FUNCTION
    lookup_cursor      integer;
    ignore          integer;
    VARvalue          number;
    VARsql_string     VARCHAR2(200);
    begin
    lookup_cursor := DBMS_SQL.open_cursor;
    VARsql_string := SOME GENERATED SQL STATEMENT;
    DBMS_SQL.PARSE( lookup_cursor,
              VARsql_string,
              DBMS_SQL.NATIVE);
    DBMS_SQL.DEFINE_COLUMN( lookup_cursor, 1, VARvalue);
    ignore := DBMS_SQL.EXECUTE(lookup_cursor);
    loop
         IF DBMS_SQL.FETCH_ROWS(lookup_cursor) > 0 THEN
         DBMS_SQL.COLUMN_VALUE(lookup_cursor, 1, VARvalue);
         ELSE
         EXIT;
         END IF;
    END LOOP;
    RETURN VARvalue;
    end TEST_FUNCTION;
    The error I received during execution of TEST_PROC is:
    ORA-06571: Function TEST_FUNCTION does not guarantee not to update database
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 239
    ORA-06512: at "SYS.DBMS_SQL", line 32
    It may seem like the example procedure doesnt need to use a dynamic SQL execution to call TEST_FUNCTION but the actual code that I extracted from does.
    Does Oracle 7 always treat the dynamic SQL command set as some kind of update statement? Is that a bug? I understand that the EXECUTE IMMEDIATE command in Oracle 8i will replace the old command set found in the above examples. Will using the new EXECUTE IMMEDIATE command in Oracle 8i solve this problem?
    Thank you for any help,
    Tony

    In Oracle 7, for a function to be called from a select statement it has to follow the 'purity rule' that it does not modify any database table or package variable.
    Probably you will have to use the compiler directive PRAGMA RESTRICT_REFERENCES (WNDS,WNPS) on your TEST_FUNCTION so that it can be called within a SQL statement.
    This restriction is removed in Oracle 8i onwards.
    Hope this solves your problem.
    Regards

  • Monitoring pl/sql execution from Enterprise Manager

    I need to implement monitoring of PL/SQL code from within Oracle Enterprise
    Manger 10g. OEM has Custom user defined metrics (UDM) that allow one to issue
    queries against a database and decide whether the output from the query is a
    warning or a critical alert based on some threshold.
    In my case, my pl/sql will write to a database table that OEM will monitoring by
    querying periodically.
    My question is how does OEM know not to report on the same error about the same
    session multiple times. Once OEM has detected that my PL/SQL routine generated
    an exception during one of its execution, how will know not to alert on the same
    exception from the same pl/sql execution, the next time it's querying the
    database?
    It almost sound like the SQL query OEM will be executing needs to know what it
    reported on before.
    Any clarity on this would be appreciated.

    ok ..thanx .. can i view all historical SQL Text that is executed by a perticuler User say SCOTT.??? In the same page within SQL DETAIL you can find task owner also,

  • Teststand Multi UUT execution Timing

    Dear All,
       I am working on Multi uut testsystem where I have to tests 5 UUT in parallel, I am using Labview adapter,with Batch process model and testing energy meters where I have hardware suitable for 5 UUT. My question is My execution timing for 1,2 .And 5 uut at a time is different, Ex.. I an getting 1 UUT tested in 5 minutes and when I starts testing when I start testing 2 UUT at the same time My total execution time for same steps and sequence increases to 7 minutes.
    Pl suggest how I can achieve same timing which I am getting for single UUT for more than one UUT execution.

    Doug, I have shared hardware and it is source calibrator for current and voltage which is wired in parallel to all 5 UUT so that it can source to all UUT at the same time.My report generation is disabled and there is no on-fly report ON.I am doing my report generation using the one labview VI where I formatted report at the end of tests so while running the tests report generation not involved.I have around 65 steps in one sequence which made for calibration.
    To get same time of execution for 5 UUT as single UUT do I need to make my labview code module as reentrant? or do I need to make multi thread in labview vi code module like each socket will have separate loop execution inside the VI.? attaching here .seq file for your reference
    Attachments:
    PM5350 Multi UUT Test.seq ‏88 KB

  • SSMA "Loading to database new table File Name.dbo[Table] ...sql execution failed

    In this case I had already processed this table once before 'no changes' and processed the second time I received this error ...sql execution Failed. It's like the sql server 2008 R2 doesn't see or detect the process. Starting Phase #0 Synchronizing Database:
    then it shows 'Loading to database new table file name.dbo[table] ... sql execution failed (this is my issue)

    Hi TheJudge2,
    Based on my understanding, you have installed SQL Server Migration Assistant successfully then you perform migration. After migration, you can’t find the table which you want to migrate to SQL Server 2008 R2 under the database in your SQL Server Management
    Studio, then you perform migration again. Then error message “Loading to database new table file name.dbo[table] ... sql execution failed” is thrown out. Please correct me if I misunderstand your meaning.
    Firstly, I would like to know whether you perform migration from Access database to SQL Server. I have performed migration from Access database to SQL Server in my lab environment.  Based on my test, I could migrate Access database to SQL Server successfully
    and table existed under the database in SQL Server Management Studio after migration.
    Besides, “sql execution failed” is a general error message. It is hard to find out the cause from this error message. Please check the information under the Output in SQL Server Migration Assistant again. It would be better if you can provide the complete
    output information for our deep analysis.
    Best regards,
    Qiuyun Yu

  • Execution timing LV4

    Hi I am having problems with execution timing of my main vi.
    Details:
    Win2000
    Labview 4.01
    The problem lies in the execution of a for loop and the use of a AI multipoint vi for obtaining 2 waveforms. The analog input and the first structure within the for loop are contained within sub vi's.
    When run, the for loop must wait to be executed AFTER the analog input has fully completed. This defeats the entire purpose of what I am trying to do.
    The for loop is used to communicate with a serial device using NI-VISA, and all the inputs for the loop are ready prior to the execution of the data aquisition.
    any ideas how I can get analog input and the for loop and the data acquisition vi to start simultaneously????
    Stuart

    I am certain there is no data dependency between the two strucutres. I tried a wait function but it didn't seem to have any effect. I also tried a while loop in place of the for loop. Still no change.
    The main vi which call the sub vi's and the sub vi's themselves are attached. They are programmed in LV4.01
    Attachments:
    SinePW.vi ‏70 KB
    mainVI.vi ‏195 KB
    DAQ.vi ‏132 KB

  • How many days old we can see SQL Executions OEM 11g

    one of my technical guy asked me 5 days back sql session information how many days old we can see SQL Executions OEM 11g ..?

    Metric Historical Information will be saved for a year by default.
    Check http://download.oracle.com/docs/cd/E11857_01/em.111/e16790/repository.htm#i1030660
    SQL Statement execution might be analyzed from AWR snapshots using ADDM.
    You can keep AWR Snapshots as long as you like.
    Bare in mind that this will occupy database space.
    From the Database Home page select the Server tab and select the Automatic Workload Repository link to set Snapshot Retention
    Regards
    Rob
    http://oemgc.wordpress.com

  • Slow sql execution

    I have SQL query retreiving lots of data from several tables, and having specific condition for nohem as it is displayed in following subquery:
    ss.nohem=(select Max(ss.nohem)
    from sschem ss
    where nohem in (3,5,6)
    and TRIM(ss.id)=TRIM(hc.id)
    As I notice, this subquery slows down main SQL execution (besides the tables are large and not well organazied).
    select ss.nohem, hc.time, hc.id, hc.shift, hc.crew, tm.qualityorg,
    ss.c, ss.si, ss.mn, ..., ..., ss.ca,
    l2_min.c as c_min, l2_max.c as c_max,
    l2_min.si as si_min, l2_max.si as si_max,
    l2_min.mn as mn_min, l2_max.mn as mn_max,
    l2_min.ca as ca_min, l2_max.ca as ca_max,
    tm.quality
    from sschem ss, tmelt tm, h_cast hc,
    l2_chem_grade l2_min, l2_chem_grade l2_max
    where (hc.time > {?from} and hc.time <= {?to})
    and ss.nohem=(select Max(ss.nohem)
    from sschem ss
    where nohem in (3,5,6)
    and TRIM(ss.id)=TRIM(hc.id)
    and tm.qualityorg=l2_min.quality_code and l2_min.range_type='MIN'
    and tm.qualityorg=l2ch_max.quality_code and l2_max.range_type='MAX'
    and TRIM(ss.id)=TRIM(tm.id)
    and TRIM(hc.id)=TRIM(tm.id)
    and TRIM(ss.id)=TRIM(hc.id)
    order by hc.time
    How can I reorganize this query to make its execution faster?
    Thanks!

    Problem with the sub-query is likely a full table scan needs to be performed. The predicate "TRIM(ss.id)=TRIM(hc.id)" uses a function to convert the searched column.
    This means reading every row applicable, applying the TRIM function to the ID column, and then evaluating the predicate. If the ID column is indexed, the index is made useless by the function.
    Solution in this case - either make use of a function index, or better still, apply the TRIM via the INSERT/UPDATE trigger and create a normal index on the ID column.
    Second problem is that the sub-select is ran for every single row selected in the main loop - it is a corellated query as the predicate for the sub-query includes a value from the row from the main query.
    So if the main query hits 10,000 rows, this sub-query will be executed 10,000 times. With the sub-query doing a full table scan, this is very, very expensive.
    Solutions. Ensure that all filters and processing are done (upfront) to reduce the result of the main query to a minimum, in order to reduce the number of sub-queries to perform (1 per row) to a minimum. Or rethink the logic and design of the entire query and do away together with the corellated sub-query.

Maybe you are looking for

  • Freeze function in logic 8?

    Can't find the freeze button on the channel strips - is it in pref's somewhere?

  • My safari doesn't seem to work well...Please help me..=[

    When i'm using safari, if i wan to go back to the previous page, i just have to slide with 2 fingers form the left to right.But if i do that now, the whole tab is useless. Anyone help me please?=]

  • How to use Flash to create an interactive diagram

    Hi all. I am an extreme newbie. I would like to create an interactive diagram and somebody said I should use Flash to do it. The idea is to create an organisational chart (like the ones you can produce in MS Word 2010). Each position will have its ow

  • The question about AppStore

    When I buy something asked me the question I dont know why I want to change the question or I've forgotten the question this is in AppStore

  • BOE XI R2 compatibility with SAP GUI 7.1

    Hi Experts, Currently, my company has BO XI R2 SP2 working with SAP BW 3.5. We use BOE XI R2 integration kit for SAP which is compatible with SAP GUI 6.4 Now we have upgraded system to BI 7.0. We also plan to upgrade the SAP GUI version to 7.1 as SAP