Long running sql query

All,
I'm new for sql query tuning. My select sql query is running more than 5-6 hours to complete and it is using bind variable. I'm using OEM to monitor the query. I can see stats are upto date and no blocking sessions and no object locks in db level. Can anyone guide me where I have to look and what should be done to increase the performance?
Thanks.

Read FAQ: {message:id=9360003}
And {message:id=9360002}

Similar Messages

  • Long running sql

    Hi All,
    I have a long running sql which I am tuning for oltp environment.
    Here is the sql
    explain plan for
    SELECT a.* ,rownum as rnm
    FROM ( SELECT /*+ FIRST_ROWS(100) STAR_TRANSFORMATION PARALLEL(PLS,2) */
    /* End of Hint in Query Builder */
    PLD.PRVDR_LCTN_IID AS "ProviderLocationIid", PLD.PRVDR_LCTN_DTL_SID AS "ProviderLocationDetailSid",
    PLD.ENRLMNT_TYPE_CID AS "EnrollMentTypeCid", PLD.PRVDR_TYPE_CODE AS "ProviderTypeCode",
    PLD.MAINECARE_ID AS "Provider Id", PLD.PRVDR_NAME AS "Provider Name",
    PLD.PRVDR_TYPE_CODE || '-' || PLD.PRVDR_TYPE_NAME AS "Provider Type",
    TO_CHAR(PLS.FROM_DATE,'MM/dd/yyyy') AS "Start Date",
    TO_CHAR(PLS.TO_DATE,'MM/dd/yyyy') AS "End Date", PLD.COUNTY_NAME AS "County",
    PLD.CITY_TOWN_NAME AS "Town", PLD.ENRLMNT_TYPE_NAME AS "Enrollment Type",
    PLS.STATUS_CID AS "StatusCid", STSBS.STATUS_NAME AS "Business Status",
    PLD.LCTN_PHONE_NMBR AS "Phone Number", PLD.PRVDR_TYPE_NAME AS "PrvdrTypeName",
    SP.SPCLTY_CODE||'-'||SP.SPCLTY_NAME ||'/'|| SP1.SPCLTY_CODE||'-'||
    SP1.SPCLTY_NAME AS "Specialty/Subspecialty",
    UPPER(SP1.SPCLTY_CODE) AS "SubSpclty", UPPER(SP.SPCLTY_CODE) AS "Spclty"
    FROM /*Query Builder Clause*/
    STATUS STS,
    STATUS STSBS,
    SPECIALTY_SUBSPECIALTY SSP,
    (SELECT PRVDR_LCTN_STATUS_SID, PRVDR_LCTN_IID, PRVDR_LCTN_DTL_SID, FROM_DATE, TO_DATE,
    STATUS_TYPE_CID, STATUS_CID, OPRTNL_FLAG,
    FN_GETANCHORDT(FROM_DATE,TO_DATE) AS ANCHOR_DATE
    FROM PRVDR_LCTN_STATUS
    WHERE STATUS_TYPE_CID = 1
    AND OPRTNL_FLAG = 'A'
    ) PLS,
    PRVDR_LCTN_X_SPCLTY_SUBSPCLTY PXSP,
    PRVDR_LCTN_STATUS PLSBS,
    PROVIDER_LOCATION_DETAIL PLD,
    SPECIALTY SP1,
    SPECIALTY SP
    WHERE
    STS.STATUS_TYPE_CID = 1
    AND STS.STATUS_CID = 2
    AND STSBS.STATUS_TYPE_CID = 15
    AND PLSBS.OPRTNL_FLAG = 'A'
    --          UPPER(UPPER(SP1.SPCLTY_CODE)) LIKE UPPER('1%')
              AND SP1.SPCLTY_CODE LIKE '1%'
    -- AND UPPER(UPPER(SP.SPCLTY_CODE)) LIKE UPPER('1%')
    AND SP.SPCLTY_CODE LIKE '1%'
    AND PLS.OPRTNL_FLAG = 'A'
    AND SP1.OPRTNL_FLAG = 'A'
    AND PXSP.OPRTNL_FLAG = 'A'
    AND PXSP.STATUS_CID = 2
    AND SSP.OPRTNL_FLAG = 'A'
    AND SP.OPRTNL_FLAG = 'A'
    AND PLS.ANCHOR_DATE >= PLSBS.FROM_DATE
    AND PLS.ANCHOR_DATE <= PLSBS.TO_DATE
    AND PLS.STATUS_TYPE_CID = STS.STATUS_TYPE_CID
    AND PLS.STATUS_CID = STS.STATUS_CID
    AND PLD.PRVDR_LCTN_DTL_SID = PLS.PRVDR_LCTN_DTL_SID
    AND PLSBS.PRVDR_LCTN_IID = PLS.PRVDR_LCTN_IID
    AND PLSBS.STATUS_TYPE_CID = STSBS.STATUS_TYPE_CID
    AND PLSBS.STATUS_CID = STSBS.STATUS_CID
    AND PLS.ANCHOR_DATE >= SP1.FROM_DATE
    AND PLS.ANCHOR_DATE <= SP1.TO_DATE
    AND PXSP.PRVDR_LCTN_IID = PLS.PRVDR_LCTN_IID
    AND PXSP.SPCLTY_SUBSPCLTY_SID = SSP.SPCLTY_SUBSPCLTY_SID
    AND PLS.ANCHOR_DATE >= PXSP.FROM_DATE
    AND PLS.ANCHOR_DATE <= PXSP.TO_DATE
    AND SSP.SPCLTY_CODE = SP.SPCLTY_CODE
    -- AND SSP.SUBSPCLTY_CODE = SP1.SPCLTY_CODE
    AND SSP.SUBSPCLTY_CODE = SP1.SPCLTY_CODE
    AND PLS.ANCHOR_DATE >= SSP.FROM_DATE
    AND PLS.ANCHOR_DATE <= SSP.TO_DATE
    AND PLS.ANCHOR_DATE >= SP.FROM_DATE
    AND PLS.ANCHOR_DATE <= SP.TO_DATE
    ORDER BY /*Query Builder Clause*/
    "Provider Id" DESC
    ) A
    WHERE rownum < 101
    Here is the Emplain plan
    SQL> @c:\mohammed\tune\UTLXPLS
    Plan Table
    | Operation | Name | Rows | Bytes| Cost | Pstart| Pstop |
    | SELECT STATEMENT | | | | | | |
    | COUNT STOPKEY | | | | | | |
    | VIEW | | | | | | |
    | SORT ORDER BY STOPKEY | | 1 | 358 | 120 | | |
    | SORT ORDER BY STOPKEY | | | | | | |
    | NESTED LOOPS | | 1 | 358 | 117 | | |
    | NESTED LOOPS | | 1 | 313 | 116 | | |
    | NESTED LOOPS | | 1 | 268 | 115 | | |
    | NESTED LOOPS | | 1 | 240 | 114 | | |
    Plan Table
    | NESTED LOOPS | | 1 | 209 | 112 | | |
    | NESTED LOOPS | | 1 | 95 | 111 | | |
    | NESTED LOOPS | | 1 | 74 | 110 | | |
    | NESTED LOOPS | | 7 | 294 | 103 | | |
    | INDEX UNIQUE SCAN |SYS_C00489936 | 1 | 7 | | | |
    | TABLE ACCESS FULL |PRVDR_LCTN_STATUS | 1K| 53K| 102 | | |
    | TABLE ACCESS BY INDEX ROWID |PRVDR_LCTN_STATUS | 57K| 1M| 2 | | |
    | INDEX RANGE SCAN |TUNE_PNBS2_1 | 57K| | 1 | | |
    | TABLE ACCESS BY INDEX ROWID |STATUS | 5 | 105 | 1 | | |
    | INDEX UNIQUE SCAN |SYS_C00489936 | 5 | | | | |
    | TABLE ACCESS BY INDEX ROWID |PROVIDER_LOCATION_D | 40K| 4M| 1 | | |
    Plan Table
    | INDEX UNIQUE SCAN |XPKPROVIDER_LOCATIO | 40K| | | | |
    | TABLE ACCESS BY INDEX ROWID |PRVDR_LCTN_X_SPCLTY | 1M| 39M| 3 | | |
    | INDEX RANGE SCAN |TUNE_SARWAR_0503200 | 1M| | 2 | | |
    | TABLE ACCESS BY INDEX ROWID |SPECIALTY_SUBSPECIA | 549 | 15K| 1 | | |
    | INDEX UNIQUE SCAN |SYS_C00489888 | 549 | | | | |
    | TABLE ACCESS BY INDEX ROWID |SPECIALTY | 11 | 495 | 1 | | |
    | INDEX UNIQUE SCAN |SYS_C00489875 | 11 | | | | |
    | TABLE ACCESS BY INDEX ROWID |SPECIALTY | 11 | 495 | 1 | | |
    | INDEX UNIQUE SCAN |SYS_C00489875 | 11 | | | | |
    32 rows selected.
    I have tried with several hints and several driving tables and tires. Any help in this regard will be highly appreciated.
    Thanks a lot,
    Mohammed Sarwar
    ocp dba
    Email: [email protected]
    [email protected]
    Phone : 301-944-2029 w
    913-484-9204 cell

    This should be better. Any help on tuning the above sql statement using the following explain plan will be highly appreciated.
    Plan Table
    | Operation ------------------| Name -------------| Rows | Bytes| Cost | Pstart| Pstop |
    | SELECT STATEMENT -----------| ------------------| -----| -------|------| | |
    | COUNT STOPKEY --------------|-------------------|------|--------|------| | |
    | VIEW -----------------------|-------------------|----- | -------| -----| | |
    | SORT ORDER BY STOPKEY ------|------------------ |--- 1 | ---358 | 120 -| | |
    | SORT ORDER BY STOPKEY ------| ------------------|----- |------- | -----| | |
    | NESTED LOOPS ---------------|-------------------|--- 1 |--358 -|- 117 | | |
    | NESTED LOOPS ---------------|----------------- -|--- 1 | -313 -| -116 | | |
    | NESTED LOOPS ---------------|----------------- -|--- 1 | 268-- | 115 -| | |
    | NESTED LOOPS--------------- |-------------------| --1- | -240 -| -114 | | |
    Plan Table
    | NESTED LOOPS--------------- |------------------ | ---1 |- 209 -|- 112 | | |
    | NESTED LOOPS--------------- | ------------------|--- 1 |-- 95- | -111 | | |
    | NESTED LOOPS ---------------|----- -------------|--- 1 |-- 74 -| -110 | | |
    | NESTED LOOPS ---------------|----------------- -|--- 7 | -294- |- 103| | |
    | INDEX UNIQUE SCAN ----------|SYS_C00489936------| ---1 |--- 7--|-----| | |
    | TABLE ACCESS FULL ----------|PRVDR_LCTN_STATUS -| --1K | 53K-- | 102 | | |
    | TABLE ACCESS BY INDEX ROWID |PRVDR_LCTN_STATUS- | 57K -|---- 1M|-- 2 | | |
    | INDEX RANGE SCAN -----------|TUNE_PNBS2_1 ------| 57K- |------ |-- 1 | | |
    | TABLE ACCESS BY INDEX ROWID |STATUS------------ | 5 |105----|-- 1 | | |
    | INDEX UNIQUE SCAN---------- |SYS_C00489936 -----| 5--- | ------|-----| | |
    | TABLE ACCESS BY INDEX ROWID-|PROVIDER_LOCATION_D| 40K | 4M----|-- 1 | | |
    Plan Table
    | INDEX UNIQUE SCAN ----------|XPKPROVIDER_LOCATIO| 40K |----- |----- | | |
    | TABLE ACCESS BY INDEX ROWID-|PRVDR_LCTN_X_SPCLTY| 1M -|---39M|--- 3 | | |
    | INDEX RANGE SCAN -----------|TUNE_SARWAR_0503200| 1M -| -----|--- 2 | | |
    |TABLE ACCESS BY INDEX ROWID- |SPECIALTY_SUBSPECIA| 549 |---15K| ---1 | | |
    | INDEX UNIQUE SCAN ----------|SYS_C00489888 -----| 549 |----- | -----| | |
    |TABLE ACCESS BY INDEX ROWID- |SPECIALTY ---------| 11- |---495|--- 1 | | |
    | INDEX UNIQUE SCAN ----------|SYS_C00489875----- | 11 -|----- |----- | | |
    |TABLE ACCESS BY INDEX ROWID -|SPECIALTY ---------| 11- |---495|----1 | | |
    | INDEX UNIQUE SCAN-----------|SYS_C00489875----- | 11 -|----- |----- | | |
    --------------------------------------------------------------------------------

  • Long Running SQL Queries

    We have a customer that runs our Crystal Reports and they have complained that some of the reports cause long running sql queries and they have to kill these queries manually from SQL Management tools. We have changed the code so that we now dispose the report source and viewer objects as we call .dispose() function on them;
    reportSource.dispose();
    viewer.dispose();
    At first this seemed work but customer later complained that the issue still occurs. Can anyone help with why some of these CR queries are still running way after report is generated (with correct set of data), and based on the customer some of them running for more than 2 hours? What else can we do to make sure that all CR related queries cease to exist once report is generated? Appreciate all the help.

    1. Run the report from with Crystal designer. You should see the query being sent to DB server. After the report is viewed and you close it in designer, do you see the DB connection being dropped? If not, this may not be a SDK\ API related issue.
    2. Try using latest set of CRJ Jars [here|http://downloads.businessobjects.com/akdlm/crystalreportsforeclipse/2_0/crjava-runtime_12.2.213.zip] in your application. Also update the crystalreportviewers folder with the new viewer found at this link.
    3. Make sure that you are calling reportClientDocument.close() at the end when user is done viewing the report.
    4. When you say logn running queries are seen in DB, are you referring to a DB connection left open? or is it actually running any query and returning results?

  • Long Running SQL and ORDS Spawns Multiple Database Sessions

    Hi all.
    We have a strange situation when accessing a long running SQL Report (a single APEX Page).
    The SQL takes about 15 mins to run but when I monitor what database sessions are spawned by the APEX Listener, I see multiple sessions all executing the same SQL. It appears that after 6 minutes, the APEX Listener spawns a new database session to execute the same SQL.
    Has anyone seen this before and if so, is there a key setting I am missing as I don't want this to happen. I am new to the APEX Listener and WebLogic so apologies if this is the way it's meant to work but it seems odd that after a certain amount of time (6 minutes in my case) a new database session is spawned to do the same work.
    We are running:
    WebLogic: 10.3.0.6
    APEX_LISTENER_VERSION 2.0.0.354.17.06
    Datadate: 11.2.0.3.0 Production
    APEX: 4.2.1.00.08
    Cheers for any help.
    Duncs

    Hi Duncan,
    With all respect, you should please rethink your interface.  I would never consider writing a Web application with a request that knowingly takes 15 minutes to return the results.  You can consider doing this asynchronously via DBMS_SCHEDULER and then alerting the user (via email, perhaps) that their results are ready.  Or if you can precompute this in advance, consider using materialized views so that the user's response time is sub-second.
    In an era where the patience of the average end-user is measured in single-digit seconds, it is impractical to ever expect an end-user to wait 15 minutes for their resultant Web page.
    Joel

  • Is there a way to get long running SQL Agent jobs information using powershell?

    Hi All,
    Is there a way to get long running SQL Agent jobs information using powershell for multiple SQL servers in the environment?
    Thanks in Advance.
    --Hunt

    I'm running SQL's to fetch the required details and store it in centralized table. 
    foreach ($svr in get-content "f:\PowerSQL\Input\LongRunningJobsPowerSQLServers.txt"){
    $dt = new-object "System.Data.DataTable"
    $cn = new-object System.Data.SqlClient.SqlConnection "server=$svr;database=master;Integrated Security=sspi"
    $cn.Open()
    $sql = $cn.CreateCommand()
    $sql.CommandText = "SELECT
    @@SERVERNAME servername,
    j.job_id AS 'JobId',
    name AS 'JobName',
    max(start_execution_date) AS 'StartTime',
    max(stop_execution_date)AS 'StopTime',
    max(avgruntimeonsucceed),
    max(DATEDIFF(s,start_execution_date,GETDATE())) AS 'CurrentRunTime',
    max(CASE WHEN stop_execution_date IS NULL THEN
    DATEDIFF(ss,start_execution_date,stop_execution_date) ELSE 0 END) 'ActualRunTime',
    max(CASE
    WHEN stop_execution_date IS NULL THEN 'JobRunning'
    WHEN DATEDIFF(ss,start_execution_date,stop_execution_date)
    > (AvgRunTimeOnSucceed + AvgRunTimeOnSucceed * .05) THEN 'LongRunning-History'
    ELSE 'NormalRunning-History'
    END) 'JobRun',
    max(CASE
    WHEN stop_execution_date IS NULL THEN
    CASE WHEN DATEDIFF(ss,start_execution_date,GETDATE())
    > (AvgRunTimeOnSucceed + AvgRunTimeOnSucceed * .05) THEN 'LongRunning-NOW'
    ELSE 'NormalRunning-NOW'
    END
    ELSE 'JobAlreadyDone'
    END)AS 'JobRunning'
    FROM msdb.dbo.sysjobactivity ja
    INNER JOIN msdb.dbo.sysjobs j ON ja.job_id = j.job_id
    INNER JOIN (
    SELECT job_id,
    AVG
    ((run_duration/10000 * 3600) + ((run_duration%10000)/100*60) + (run_duration%10000)%100)
    +
    STDEV
    ((run_duration/10000 * 3600) + ((run_duration%10000)/100*60) + (run_duration%10000)%100) AS 'AvgRuntimeOnSucceed'
    FROM msdb.dbo.sysjobhistory
    WHERE step_id = 0 AND run_status = 1
    GROUP BY job_id) art
    ON j.job_id = art.job_id
    WHERE
    (stop_execution_date IS NULL and start_execution_date is NOT NULL) OR
    (DATEDIFF(ss,start_execution_date,stop_execution_date) > 60 and DATEDIFF(MINUTE,start_execution_date,GETDATE())>60
    AND
    CAST(LEFT(start_execution_date,11) AS DATETIME) = CAST(LEFT(GETDATE(),11) AS DATETIME) )
    --ORDER BY start_execution_date DESC
    group by j.job_id,name
    $rdr = $sql.ExecuteReader()
    $dt.Load($rdr)
    $cn.Close()
    $dt|out-Datatable
    Write-DataTable -ServerInstance 'test124' -Database "PowerSQL" -TableName "TLOG_JobLongRunning" -Data $dt}
    You can refer the below link to refer out-datatable and write-dataTable function.
    http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/01/use-powershell-to-collect-server-data-and-write-to-sql.aspx
    Once we've the table details, I'm sending one consolidated email to automatically.
    --Prashanth

  • Need checkbox onclick somehow to run SQL query

    Hello all,
    Now, I know directly I cannot do this with a javascript function.  What I need to do is with a checkbox onclick
    set a hidden field to the type of the data that is selected by the checkbox.  So, if I select the name of a person,
    the onclick method needs to let the hidden field know we have a "person" entity type. I need this type because
    when I do my true submit, that form field when read will denote what next page I need to bring up in a new tab.
    The question I have is ok, I can attempt to do this a couple of ways, following:
    1)  Come up with an AJAX call that will run a function on the server.  What I do worry about is
    submitting the page and ending up losing boxes that were checked.  I also don't want a long
    form submittal after every click.
    OR
    2)  Forget the onclick method, create a blank .cfm form, then use that form to run the query for the
    types of data, and then call the page to be displayed?  Again, I'm new, so I don't know if this could
    be weird in how the page comes up for display?
    Thanks in advance!!!!!

    Hey Dan,
    Yep, I'm very new at using CF, so I pretty much stink at it compared to you all.  However, I fixed my one problem in that I don't need
    to do anything with SQL queries with onclick.  I combined a bunch of forms into one and process stuff on that page.  Matter of fact,
    I needed to do that.
    However, what I do have a problem with is one last part of my keeping checkbox values when paging.  I can do almost everything,
    meaning, keep track of checkbox values when checked by having a list of those values in session.  I can check the boxes when
    I go back to the page with a simple <CFIF> block when the checkboxes are created for the page.
    The issue I have now is how I can delete a value from the session list when a checkbox is unchecked.  I don't know if I should
    keep track of the exact page number, or whatnot.  All I have now is a list of node ids.
    Any ideas?
    Thanks,
    Ed

  • How to run sql query in bat file in task schedular at every 10 seconds

    This is my sql script :
    DECLARE @countRows INT,
    @currDate DATE,
    @checkForTasks INT,
    @created_by_id INT,
    @gst_ID int;
    SET @currDate = Getdate()
    SET @countRows = (SELECT Count(*)
    FROM [dbo].[sd_gst_effective_table]
    WHERE isapplied = 0)
    IF @countRows > 0
    -- Check for those GST''s who are not applied yet : if they are greater than 0 then perform next task
    BEGIN
    SET @checkForTasks = (SELECT Count(*)
    -- Check is current date equals to task date or not
    FROM [dbo].[sd_gst_effective_table]
    WHERE effect_date = @currDate AND isapplied = 0)
    IF @checkForTasks > 0
    -- If current date = task date then perform this task
    BEGIN
    SET @created_by_id = (SELECT TOP 1 createdby FROM [dbo].[sd_gst_effective_table] WHERE effect_date = @currDate AND isapplied = 0)
    SET @gst_ID = (SELECT gst_id FROM [dbo].[sd_gst_effective_table] WHERE effect_date = @currDate AND isapplied = 0)
    -- STEP 1 :: InActivate the existing GST according to createdbyID
    UPDATE sd_gst_rate
    SET isactive = 0,
    inactivedate = Getdate()
    WHERE isactive = 1
    AND createdby = @created_by_id
    -- STEP 2 :: Activate the New GST according to implementation date and gstID
    UPDATE sd_gst_rate
    SET isactive = 1,
    activedate = Getdate()
    WHERE id = @gst_ID
    -- STEP 3 :: Inactivate the applied GST from sd_gst_effective_table
    UPDATE [dbo].[sd_gst_effective_table] SET isApplied = 1 WHERE gst_id = @gst_ID
    END
    END
    DECLARE @Text AS VARCHAR(100)
    DECLARE @Cmd AS VARCHAR(100)
    DECLARE @value nvarchar(1000);
    SET @value = (SELECT CONVERT(TIME,GETDATE()) AS HourMinuteSeconds);
    SET @Text = 'File Writed ' + @value
    SET @Cmd ='echo ' + @Text + ' > E:\AppTextFile.txt'
    EXECUTE Master.dbo.xp_CmdShell @Cmd
    This is resided in videos folder of windows , i have created a task schedular in windows 8.1 to run daily at every 10 seconds , but it is not working ... Please tell me how to deal with it.
    Please note : This sql query is running perfectly in sql server. Query have no errors. Please check whats wrong with my time schedular. I just want my schedular to run every 10 seconds regardless of date.

    Hi Emad,
    Is your script in a ".sql" file? May I know how you configure the schedule task action?
    Since you didn't mention how you configure the schedule task, can you confirm you have followed the below step correctly?
    Save your script in a ".sql" file.
    Create a ".bat" file and call the sql file above inside with
    sqlcmd.exe, you can reference
    here.
    Configure a schedule task to run the ".bat" file in a certain interval.
    Have you tried to run the script in you bat file in a standalone commandline window? Please post the script in your bat file, It can help to diagnose the issue.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Problem in running sql query

    Hello ,
    I am using oracle 10g apex 3.2.
    I have assosiated 2 schema "vpmys and vp" with one workspace.
    In the application , i created a new page of report ,which is assosiated with one schema called "vp" and i wish to run this query
    select * from vpmys.t_devotees
    minus
    select * from vp.t_devotees
    Same database dmp is installed in both schema except that the no of rows may be more or less in one database.So first i need to know the added rows and what are they and then insert the same no of rows into another db.
    But this doesnt run in the application.
    But it runs in the SQL Command window.
    So what way i should change the query so that it runs.
    Thanks
    Swapna

    Post your question in Application Express Forum
    Oracle Application Express (APEX)

  • Is there a fix limit how long an SQL query may be?

    Hello,
    I am currently writing an application (java/jdbc/thin-driver) which executes a simple but very big query which looks like the following:
    SELECT CALKEY, PERSNO, MANDT FROM PERSONS WHERE MANDT='1' AND PERSNO='100471' OR MANDT='1' AND PERSNO='100838' OR MANDT='1' AND PERSNO='101010' (to be continued the next 400kb)
    For now I am not able to test it with oracle but a not as professional database aborts simply by throwing an SQLException even with that "small" 400kb query, however this query could easily grow to 2-5mb too.
    Will the oracle jdbc-thin driver correctly process that large queries (and how fast?) and are there limits for the size of an SQL query?
    Thank you in advance, lg Clemens

    Hello and thats a lot for the suggestions and tips you gave me.
    where does all those 100471, 100838 came from ? would
    not it make sense to have those in the database?The problem lies in the fact that I get this data from our sap->db interface with beeing the "100471" the personal numbers of our users. So it would not make that much sence (from the performance point of view) to create a temporary table since the whole time needed to create+fill+drop the table would take longer than this approach.
    Thanks for the tips with the different synthax this really should reduce the lenght of the query.
    I also implemented a lenght-limit now, if the query string would become larger than a dynamically set limit a second query is generated and results are both added to a list.
    Thanks a lot for all this useful tips and suggestion, lg Clemens

  • UDM for long running sql

    Hi
    I am planning to use enterprise manager grid control to create a UDM for the following sql that would alert me for the sql that is running for more then a hour for all databases any ideas on how to do this
    SELECT
            substr(swn.sql_text,40),
            ||'SQL is Running on Instance ' ||s.inst_id || 'Since '|| ROUND(sl.elapsed_seconds/60) elapsed_mins,      
    FROM   gv$session_longops sl,
    gv$session s ,
    gv$sql swn
    WHERE  s.sid     = sl.sid
    AND    s.inst_id = sl.inst_id
    AND    s.serial# = sl.serial#
    AND    s.inst_id = swn.inst_id
    AND    s.sql_address = swn.address
    AND    s.sql_hash_value = swn.hash_value
    AND    sl.sofar  <> sl.totalwork
    AND    sl.totalwork <> 0
    AND    round((sl.elapsed_seconds)/60,0) > 60
    order by 7Edited by: user9243284 on Jun 7, 2010 3:48 AM

    I think you should specify:
    SQL query output: two columns
    Metric Type: String
    and the following query:
    SELECT 'NA',0
    from dual
    union
    SELECT distinct '( ' ||i.instance_name ||','|| sl.sid ||','|| sl.serial# ||', ) ' || substr(s.sql_text,1,1000) sql, ROUND(sl.elapsed_seconds/60) mins
    FROM gv$session_longops sl,
    gv$sql s,
    gv$instance i
    WHERE sl.sofar = sl.totalwork
    AND sl.totalwork = 0
    AND sl.inst_id = s.inst_id (+)
    AND sl.sql_address = s.address (+)
    AND sl.sql_hash_value = s.hash_value (+)
    AND sl.inst_id = i.inst_id
    use the select from dual, to make sure your query allways returns at least one row.
    BTW, you will find some examples of UDM creation on my blog.
    Regards
    Rob
    http://oemgc.wordpress.com

  • Killing long running SQl automatically

    I want to put a restriction on my database, if a sql query is running for more then 15 min, then killing this automatically. If this is possible kindly let me know.

    Hi,
    yes you can do that, use Resource Manager for that like described below:
    http://www.pythian.com/blog/oracle-limiting-query-runtime-without-killing-the-session/
    Best regards,
    Nikolay

  • Help me Please ..... How to Run SQL Query in Creator

    Hi all , I want to Run a SQL query in Creator how do i do it.
    If i want to retrive a set of records based on few matching fields or some join conditions , what method i can use ?
    How Can i run other SQL statements like ALTER , UPDATE , DROP ....
    Please Help me .

    Hi Hanumesh,
    To run SQL commands like ALTER, UPDATE, DROP you will have to go to the Pointbase console. Creator does not provide for database operations on the tables other than querying for data. To start the Pointbase console run startconsole.exe which can be found in <install directory>\SunAppServer8\pointbase\tools\serveroption.
    Hope this helps
    Cheers
    Girish

  • Running sql query across multiple (remote) databases

    I'd like to run a query that pulls information from multiple databases which are not on the same machine. Is this possible using SQL Developer?

    If you are still interested, there is a tool that can query multiple databases and save results in a single text file that you can then modify as necessary - see www.bsutils.com/MuSQL.html

  • Can we run SQL query on a XML file?

    Hi All
    I have an XML document which stores data of a table.
    My requirement is to retreive data from this XML document by firing SQL
    query.
    i.e "SELECT * FROM EMP" should give me the data from the EMP.XML file
    whose name is the table name.
    Does Oracle provide this feature to retreive data from an XML document
    by issuing the same SQL statement that is used in Database?
    Any pointer for this requirement is highly appreciated.
    Thanks in advance..
    Ashish

    select '<EMPLOYEE><EPNUM>' || EPNUM || '</EPNUM><EMPNAME>' || EMPNAME || '</EMPNAME></EMPLOYEE>' from EMPLOYEE;

  • Oracle 8i giving slow response when running sql query

    hi ,
    i am using oracle 8i server ;
    and sql query giving slow response before some days;
    so which parameter need to increase
    DB_BLOCK_BFFERS OR SHARE_POOL_SIZE
    CURRENT SETING IS
    DB_BLOCK_BUFFER=256000;
    SHARE POOLSIZE=300M;
    pls advice to me
    thanks

    No parameters need to be increased. Tuning is not done but making arbitrary changes to values and hoping that good things will happen by accident.
    The thing you really should be worrying about is your antique database and likely its impact on your skill set unless you are one year away from retirement.
    Where's the actual version number?
    Where's the DDL?
    Where's the DML?
    Where's the Explain Plan?

Maybe you are looking for