Too long query

Hello,
I'm working on Oracle 11.2.0.3.
I'm trying to execute this query
SELECT distinct s, prefLabel,o
FROM TABLE(SEM_MATCH('PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX orardf:<http://xmlns.oracle.com/rdf/>
SELECT *
WHERE
?s ?p ?o.
?s skos:prefLabel ?prefLabel .
filter (lang(?prefLabel ) ="fr").
filter (orardf:textContains(?prefLabel , "famille")).
SEM_Models('modelinf'),
SEM_Rulebases('SKOSCORE'),
null,
null,
null,
null ))
but it takes too long time.
I'm not sure that all the necessary index has been create on the database.
Could you help me to optimize this query ?
Thanks.
Cyril.

Hello,
this is the execution plan of this query
SELECT s, prefLabel
FROM TABLE(SEM_MATCH('PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX orardf:<http://xmlns.oracle.com/rdf/>
SELECT distinct ?s ?prefLabel
WHERE
?s rdf:type skos:Concept.
?s skos:prefLabel ?prefLabel .
filter (lang(?prefLabel ) ="fr").
filter (orardf:textContains(?prefLabel , "famille")).
SEM_Models('modelinf'),
SEM_Rulebases('SKOSCORE'),
null,
null,
null,
null ))
It takes 2.703 seconds for 12 rows
Plan hash value: 1619577833
| Id | Operation | Name | Pstart| Pstop |
| 0 | SELECT STATEMENT | | | |
| 1 | COLLECTION ITERATOR SUBQUERY FETCH | | | |
| 2 | COUNT | | | |
|* 3 | FILTER | | | |
| 4 | NESTED LOOPS | | | |
| 5 | NESTED LOOPS | | | |
| 6 | VIEW | | | |
| 7 | SORT GROUP BY | | | |
| 8 | NESTED LOOPS | | | |
| 9 | NESTED LOOPS | | | |
| 10 | NESTED LOOPS | | | |
| 11 | VIEW | | | |
| 12 | UNION-ALL | | | |
| 13 | PARTITION LIST SINGLE | | 3 | 3 |
|* 14 | INDEX RANGE SCAN | RDF_LNK_PCS_IDX | 3 | 3 |
| 15 | PARTITION LIST SINGLE | | 4 | 4 |
|* 16 | INDEX RANGE SCAN | RDF_LNK_PCSGM_IDX | 4 | 4 |
| 17 | VIEW | | | |
| 18 | UNION-ALL PARTITION | | | |
| 19 | PARTITION LIST SINGLE | | 3 | 3 |
|* 20 | INDEX RANGE SCAN | RDF_LNK_PSC_IDX | 3 | 3 |
| 21 | PARTITION LIST SINGLE | | 4 | 4 |
|* 22 | INDEX RANGE SCAN | RDF_LNK_PSCGM_IDX | 4 | 4 |
|* 23 | INDEX UNIQUE SCAN | C_PK_VID | | |
|* 24 | TABLE ACCESS BY INDEX ROWID| RDF_VALUE$ | | |
|* 25 | INDEX UNIQUE SCAN | C_PK_VID | | |
| 26 | TABLE ACCESS BY INDEX ROWID | RDF_VALUE$ | | |
|* 27 | TABLE ACCESS FULL | RDF_RI_SHAD_5$ | | |
Predicate Information (identified by operation id):
3 - filter( NOT EXISTS (SELECT 0 FROM "MDSYS"."RDF_RI_SHAD_5$"
"RDF_RI_SHAD_5$" WHERE LNNVL("RDF_RI_SHAD_5$"."ID"<>1)))
14 - access("P_VALUE_ID"=834132227519661324 AND
"CANON_END_NODE_ID"=8129753520990573772 AND "START_NODE_ID">0 AND
"START_NODE_ID" IS NOT NULL)
16 - access("P_VALUE_ID"=834132227519661324 AND
"CANON_END_NODE_ID"=8129753520990573772 AND "START_NODE_ID">0 AND
"START_NODE_ID" IS NOT NULL)
20 - access("P_VALUE_ID"=8569708817671647133 AND
"START_NODE_ID"="from$_subquery$_007"."START_NODE_ID" AND
"CANON_END_NODE_ID">0 AND "CANON_END_NODE_ID" IS NOT NULL)
filter("START_NODE_ID">0)
22 - access("P_VALUE_ID"=8569708817671647133 AND
"START_NODE_ID"="from$_subquery$_007"."START_NODE_ID" AND
"CANON_END_NODE_ID">0 AND "CANON_END_NODE_ID" IS NOT NULL)
filter("START_NODE_ID">0)
23 - access("V0"."VALUE_ID"="from$_subquery$_011"."CANON_END_NODE_ID")
24 - filter("SEM_APIS"."GETV$LANGVAL"("V0"."VALUE_TYPE","V0"."VNAME_PRE
FIX","V0"."VNAME_SUFFIX","V0"."LITERAL_TYPE","V0"."LANGUAGE_TYPE")='fr'
AND "CTXSYS"."CONTAINS"("V0"."VNAME_PREFIX",'famille'||'')>0)
25 - access("R"."S$RDFVID"="V0"."VALUE_ID")
27 - filter(LNNVL("RDF_RI_SHAD_5$"."ID"<>1))
Thanks.
Cyril

Similar Messages

  • Loop with WMI Query taking too long, need to break out if time exceeds 5 min

    I've written a script that will loop through a list of computers and run a WMI query using the Win32_Product class. I am pinging the host first to ensure its online which eliminates wasting time but the issue I'm facing is that some of the machines
    are online but the WMI Query takes too long and holds up the script. I wanted to add a timeout to the WMI query so if a particular host will not respond to the query or gets stuck the loop will break out an go to the next computer object. I've added my code
    below:
    $Computers = @()
    $computers += "BES10-BH"
    $computers += "AUTSUP-VSUS"
    $computers += "AppClus06-BH"
    $computers += "Aut01-BH"
    $computers += "AutLH-VSUS"
    $computers += "AW-MGMT01-VSUS"
    $computers += "BAMBOOAGT-VSUS"
    ## Loop through all computer objects found in $Computes Array
    $JavaInfo = @()
    FOREACH($Client in $Computers)
    ## Gather WMI installed Software info from each client queried
    Clear-Host
    Write-Host "Querying: $Client" -foregroundcolor "yellow"
    $HostCount++
    $Online = (test-connection -ComputerName ADRAP-VSUS -Count 1 -Quiet)
    IF($Online -eq "True")
    $ColItem = Get-WmiObject -Class Win32_Product -ComputerName $Client -ErrorAction SilentlyContinue | `
    Where {(($_.name -match "Java") -and (!($_.name -match "Auto|Visual")))} | `
    Select-Object Name,Version
    FOREACH($Item in $ColItem)
    ## Write Host Name as variable
    $HostNm = ($Client).ToUpper()
    ## Query Named Version of Java, if Java is not installed fill variable as "No Java Installed
    $JavaVerName = $Item.name
    IF([string]::IsNullOrEmpty($JavaVerName))
    {$JavaVerName = "No Installed"}
    ## Query Version of Java, if Java is not installed fill variable as "No Java Installed
    $JavaVer = $Item.Version
    IF([string]::IsNullOrEmpty($JavaVer))
    {$JavaVer = "Not Installed"}
    ## Create new object to organize Host,JavaName & Version
    $JavaProp = New-Object -TypeName PSObject -Property @{
    "HostName" = $HostNm
    "JavaVerName" = $JavaVerName
    "JavaVer" = $JavaVer
    ## Add new object data "JavaProp" from loop into array "JavaInfo"
    $JavaInfo += $JavaProp
    Else
    {Write-Host "$Client didn't respond, Skipping..." -foregroundcolor "Red"}

    Let me give you a bigger picture of the script. I've included the emailed table the script produces and the actual script. While running the script certain hosts get hung up when running the WMI query which causes the script to never complete. From one of
    the posts I was able to use the Get-WmiCustom function to add a timeout 0f 15 seconds and then the script will continue if it is stuck. The problem is when a host is skipped I am not aware of it because my script is not reporting the server that timed out.
    If you look at ZLBH02-VSUS highlighted in the report you can see that its reporting not installed when it should say something to the effect query hung.
    How can I add a variable in the function that will be available outside the function that I can key off of to differentiate between a host that does not have the software installed and one that failed to query?
    Script Output:
    Script:
    ## Name: JavaReportWMI.ps1 ##
    ## Requires: Power Shell 2.0 ##
    ## Created: January 06, 2015 ##
    <##> $Version = "Script Version: 1.0" <##>
    <##> $LastUpdate = "Updated: January 06, 2015" <##>
    ## Configure Compliant Java Versions Below ##
    <##> $java6 = "6.0.430" <##>
    <##> $javaSEDEVKit6 = "1.6.0.430" <##>
    <##> $java7 = "7.0.710" <##>
    <##> $javaSEDEVKit7 = "1.7.0.710" <##>
    <##> $java8 = "8.0.250" <##>
    <##> $javaSEDDEVKit8 = "1.8.0.250" <##>
    ## Import Active Directory Module
    Import-Module ActiveDirectory
    $Timeout = "False"
    Function Get-WmiCustom([string]$computername,[string]$namespace,[string]$class,[int]$timeout=15)
    $ConnectionOptions = new-object System.Management.ConnectionOptions
    $EnumerationOptions = new-object System.Management.EnumerationOptions
    $timeoutseconds = new-timespan -seconds $timeout
    $EnumerationOptions.set_timeout($timeoutseconds)
    $assembledpath = "\\" + $computername + "\" + $namespace
    #write-host $assembledpath -foregroundcolor yellow
    $Scope = new-object System.Management.ManagementScope $assembledpath, $ConnectionOptions
    $Scope.Connect()
    $querystring = "SELECT * FROM " + $class
    #write-host $querystring
    $query = new-object System.Management.ObjectQuery $querystring
    $searcher = new-object System.Management.ManagementObjectSearcher
    $searcher.set_options($EnumerationOptions)
    $searcher.Query = $querystring
    $searcher.Scope = $Scope
    trap { $_ } $result = $searcher.get()
    return $result
    ## Log time for duration clock
    $Start = Get-Date
    $StartTime = "StartTime: " + $Start.ToShortTimeString()
    ## Environmental Variables
    $QueryMode = $Args #parameter for either "Desktops" / "Servers"
    $CsvPath = "C:\Scripts\JavaReport\JavaReport" + "$QueryMode" + ".csv"
    $Date = Get-Date
    $Domain = $env:UserDomain
    $HostName = ($env:ComputerName).ToLower()
    ## Regional Settings
    ## Used for testing
    IF ($Domain -eq "abc") {$Region = "US"; $SMTPDomain = "abc.com"; `
    $ToAddress = "[email protected]"; `
    $ReplyDomain = "abc.com"; $smtpServer = "relay.abc.com"}
    ## Control Variables
    $FromAddress = "JavaReport@$Hostname.na.$SMTPDomain"
    $EmailSubject = "Java Report - $Region"
    $computers = @()
    $computers += "ZLBH02-VSUS"
    $computers += "AUTSUP-VSUS"
    $computers += "AppClus06-BH"
    $computers += "Aut01-BH"
    $computers += "AutLH-VSUS"
    $computers += "AW-MGMT01-VSUS"
    $computers += "BAMBOOAGT-VSUS"
    #>
    ## Loop through all computer objects found in $Computes Array
    $JavaInfo = @()
    FOREACH($Client in $Computers)
    ## Gather WMI installed Software info from each client queried
    Clear-Host
    Write-Host "Querying: $Client" -foregroundcolor "yellow"
    $HostCount++
    $Online = (test-connection -ComputerName ADRAP-VSUS -Count 1 -Quiet)
    IF($Online -eq "True")
    $ColItem = Get-WmiCustom -Class Win32_Product -Namespace "root\cimv2" -ComputerName $Client -ErrorAction SilentlyContinue | `
    Where {(($_.name -match "Java") -and (!($_.name -match "Auto|Visual")))} | `
    Select-Object Name,Version
    FOREACH($Item in $ColItem)
    ## Write Host Name as variable
    $HostNm = ($Client).ToUpper()
    ## Query Named Version of Java, if Java is not installed fill variable as "No Java Installed
    $JavaVerName = $Item.name
    IF([string]::IsNullOrEmpty($JavaVerName))
    {$JavaVerName = "No Installed"}
    ## Query Version of Java, if Java is not installed fill variable as "No Java Installed
    $JavaVer = $Item.Version
    IF([string]::IsNullOrEmpty($JavaVer))
    {$JavaVer = "Not Installed"}
    ## Create new object to organize Host,JavaName & Version
    $JavaProp = New-Object -TypeName PSObject -Property @{
    "HostName" = $HostNm
    "JavaVerName" = $JavaVerName
    "JavaVer" = $JavaVer
    ## Add new object data "JavaProp" from loop into array "JavaInfo"
    $JavaInfo += $JavaProp
    Else
    {Write-Host "$Client didn't respond, Skipping..." -foregroundcolor "Red"}
    #Write-Host "Host Query Count: $LoopCount" -foregroundcolor "yellow"
    ## Sort Array
    Write-Host "Starting Array" -foregroundcolor "yellow"
    $JavaInfoSorted = $JavaInfo | Sort-object HostName
    Write-Host "Starting Export CSV" -foregroundcolor "yellow"
    ## Export CSV file
    $JavaInfoSorted | export-csv -NoType $CsvPath -Force
    $Att = new-object Net.Mail.Attachment($CsvPath)
    Write-Host "Building Table Header" -foregroundcolor "yellow"
    ## Table Header
    $list = "<table border=1><font size=1.5 face=verdana color=black>"
    $list += "<tr><th><b>Host Name</b></th><th><b>Java Ver Name</b></th><th><b>Ver Number</b></th></tr>"
    Write-Host "Building HTML Table" -foregroundcolor "yellow"
    FOREACH($Item in $JavaInfoSorted)
    Write-Host "$UniqueHost" -foregroundcolor "Yellow"
    ## Alternate Table Shading between Green and White
    IF($LoopCount++ % 2 -eq 0)
    {$BK = "bgcolor='E5F5D7'"}
    ELSE
    {$BK = "bgcolor='FFFFFF'"}
    ## Set Variables
    $JVer = $Item.JavaVer
    $Jname = $Item.JavaVerName
    ## Change Non-Compliant Java Versions to red in table
    IF((($jVer -like "6.0*") -and (!($jVer -match $java6))) -or `
    (($jName -like "*Java(TM) SE Development Kit 6*") -and (!($jName -match $javaSEDEVKit6))) -or `
    (($jVer -like "7.0*") -and (!($jVer -match $java7))) -or `
    (($jName -like "*Java SE Development Kit 7*") -and (!($jName -match $javaSEDEVKit7))))
    $list += "<tr $BK style='color: #ff0000'>"
    ## Compliant Java version are displayed in black
    ELSE
    $list += "<tr $BK style='color: #000000'>"
    ## Populate table with host name variable
    $list += "<td>" + $Item."HostName" + "</td>"
    ## Populate table with Java Version Name variable
    $list += "<td>" + $Item."JavaVerName" + "</td>"
    ## Populate table with Java Versionvariable
    $list += "<td>" + $Item."JavaVer" + "</td>"
    $list += "</tr>"
    $list += "</table></font>"
    $End = Get-Date
    $EndTime = "EndTime: " + $End.ToShortTimeString()
    #$TimeDiff = New-TimeSpan -Start $StartTime -End $EndTime
    $StartTime
    $EndTime
    $TimeDiff
    Write-Host "Total Hosts:$HostCount"
    ## Email Function
    Function SendEmail
    $msg = new-object Net.Mail.MailMessage
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)
    $msg.From = ($FromAddress)
    $msg.ReplyTo =($ToAddress)
    $msg.To.Add($ToAddress)
    #$msg.BCC.Add($BCCAddress)
    $msg.Attachments.Add($Att)
    $msg.Subject = ($EmailSubject)
    $msg.Body = $Body
    $msg.IsBodyHTML = $true
    $smtp.Send($msg)
    $msg.Dispose()
    ## Email Body
    $Body = $Body + @"
    <html><body><font face="verdana" size="2.5" color="black">
    <p><b>Java Report - $Region</b></p>
    <p>$list</p>
    </html></body></font>
    <html><body><font face="verdana" size="1.0" color="red">
    <p><b> Note: Items in red do not have the latest version of Java installed. Please open a ticket to have an engineer address the issue.</b></p>
    </html></body></font>
    <html><body><font face="verdana" size="2.5" color="black">
    <p>
    $StartTime<br>
    $EndTime<br>
    $TimeDiff<br>
    $HostCount<br>
    </p>
    <p>
    Run date: $Date<br>
    $Version<br>
    $LastUpdate<br>
    </p>
    </html></body></font>
    ## Send Email
    SendEmail

  • Time_out Dump on this query take too long time

    hi experts,
    in my report a query taking too long time
    pl. provide performance tips or suggestions
    select mkpf~mblnr  mkpf~mjahr  mkpf~usnam  mkpf~vgart    
           mkpf~xabln  mkpf~xblnr  mkpf~zshift mkpf~frbnr    
           mkpf~bktxt  mkpf~bldat  mkpf~budat  mkpf~cpudt    
           mkpf~cputm  mseg~anln1  mseg~anln2  mseg~aplzl    
           mseg~aufnr  mseg~aufpl  mseg~bpmng  mseg~bprme    
           mseg~bstme  mseg~bstmg  mseg~bukrs  mseg~bwart    
           mseg~bwtar  mseg~charg  mseg~dmbtr  mseg~ebeln    
           mseg~ebelp  mseg~erfme  mseg~erfmg  mseg~exbwr    
           mseg~exvkw  mseg~grund  mseg~kdauf  mseg~kdein    
           mseg~kdpos  mseg~kostl  mseg~kunnr  mseg~kzbew    
           mseg~kzvbr  mseg~kzzug  mseg~lgort  mseg~lifnr    
           mseg~matnr  mseg~meins  mseg~menge  mseg~lsmng    
           mseg~nplnr  mseg~ps_psp_pnr  mseg~rsnum  mseg~rspos
           mseg~shkzg  mseg~sobkz  mseg~vkwrt  mseg~waers    
           mseg~werks  mseg~xauto  mseg~zeile  mseg~SGTXT    
        into table itab                                      
           from mkpf as mkpf                                 
            inner join mseg as mseg                          
                    on mkpf~MBLNR = mseg~mblnr               
                   and mkpf~mjahr = mseg~mjahr

    no the original query is, i use where clouse with conditions.
    select mkpf~mblnr  mkpf~mjahr  mkpf~usnam  mkpf~vgart
           mkpf~xabln  mkpf~xblnr  mkpf~zshift mkpf~frbnr
           mkpf~bktxt  mkpf~bldat  mkpf~budat  mkpf~cpudt
           mkpf~cputm  mseg~anln1  mseg~anln2  mseg~aplzl
           mseg~aufnr  mseg~aufpl  mseg~bpmng  mseg~bprme
           mseg~bstme  mseg~bstmg  mseg~bukrs  mseg~bwart
           mseg~bwtar  mseg~charg  mseg~dmbtr  mseg~ebeln
           mseg~ebelp  mseg~erfme  mseg~erfmg  mseg~exbwr
           mseg~exvkw  mseg~grund  mseg~kdauf  mseg~kdein
           mseg~kdpos  mseg~kostl  mseg~kunnr  mseg~kzbew
           mseg~kzvbr  mseg~kzzug  mseg~lgort  mseg~lifnr
           mseg~matnr  mseg~meins  mseg~menge  mseg~lsmng
           mseg~nplnr  mseg~ps_psp_pnr  mseg~rsnum  mseg~rspos
           mseg~shkzg  mseg~sobkz  mseg~vkwrt  mseg~waers
           mseg~werks  mseg~xauto  mseg~zeile  mseg~SGTXT
        into table itab
           from mkpf as mkpf
            inner join mseg as mseg
                    on mkpf~MBLNR = mseg~mblnr
                   and mkpf~mjahr = mseg~mjahr
        WHERE mkpf~budat IN budat
          AND mkpf~usnam IN usnam
          AND mkpf~vgart IN vgart
          AND mkpf~xblnr IN xblnr
          AND mkpf~zshift IN p_shift
          AND mseg~bwart IN bwart
          AND mseg~matnr IN matnr
          AND mseg~werks IN werks
          AND mseg~lgort IN lgort
          AND mseg~charg IN charg
          AND mseg~sobkz IN sobkz
          AND mseg~lifnr IN lifnr
          AND mseg~kunnr IN kunnr.

  • When query is taking too long time

    When query is taking too long time,Where and how to start tuning it?
    Here i've listed few things need to be considered,out of my knowledge and understanding
    1.What the sql is waiting for(wait events)
    2.Parameter modification need to be done at system/session level
    3.The query has to be tuned (using hints )
    4.Gathering/deleting statistics
    List out any other things that need to be taken into account?
    Which approach must be followed and on what basis that approach must be considered?

    When query is taking too long time,Where and how to start tuning it?explain plan will be good start . trace also
    Here i've listed few things need to be considered,out of my knowledge and understanding
    1.What the sql is waiting for(wait events)When Oracle executes an SQL statement, it is not constantly executing. Sometimes it has to wait for a specific event to happen befor it can proceed.
    Read
    http://www.adp-gmbh.ch/ora/tuning/event.html
    2.Parameter modification need to be done at system/session levelDepend on parameter , define parameter , trace done on session level for example
    3.The query has to be tuned (using hints )Could be help you but you must know how to use .
    4.Gathering/deleting statisticsDo it in non working hours , it will impact on database performance , but its good
    List out any other things that need to be taken into account?Which account ?
    Which approach must be followed and on what basis that approach must be considered?you could use lot of tools , Trace , AWR

  • Ora-06502: variable length too long on report query xml schema download

    on shared components/report queries/edit report query/
    and downloading my queries in xml schema format (radio button).
    Get
    ORA-06502: PL/SQL: numeric or value error: raw variable length too long
    when i click the download button.
    EDIT:
    i want to add that i recently changed several columns in the database from 150 to 3000 chars long.
    Edited by: Manny Rodriguez on Oct 11, 2011 7:19 AM

    "4000 bytes is the ultimate maximum. you can say 4000 *characters* , but it'll always be limited to 4000 *bytes* . "
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:1224836384599#201073000346459201\
    "The maximum length of the column is determined by the national character set definition. Width specifications of character data type NVARCHAR2 refer to the number of characters. The maximum column size allowed is 4000 bytes."
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements001.htm#SQLRF50976
    By the way, you're treating your numbers as STRINGS, remove the quotes around your zero's.

  • My Query takes too long ...

    Hi ,
    Env   , DB 10G , O/S Linux Redhat , My DB size is about 80G
    My query takes too long ,  about 5 days to get results , can you please help to rewrite this query in a better way ,
    declare
    x number;
    y date;
    START_DATE DATE;
    MDN VARCHAR2(12);
    TOPUP VARCHAR2(50);
    begin
    for first_bundle in
    select min(date_time_of_event) date_time_of_event ,account_identifier  ,top_up_profile_name
    from bundlepur
    where account_profile='Basic'
    AND account_identifier='665004664'
    and in_service_result_indicator=0
    and network_cause_result_indicator=0
    and   DATE_TIME_OF_EVENT >= to_date('16/07/2013','dd/mm/yyyy')
    group by account_identifier,top_up_profile_name
    order by date_time_of_event
    loop
    select sum(units_per_tariff_rum2) ,max(date_time_of_event)
    into x,y
    from OLD_LTE_CDR
    where account_identifier=(select first_bundle.account_identifier from dual)
    and date_time_of_event >= (select first_bundle.date_time_of_event from dual)
    and -- no more than a month
    date_time_of_event < ( select add_months(first_bundle.date_time_of_event,1) from dual)
    and -- finished his bundle then buy a new one
      date_time_of_event < ( SELECT MIN(DATE_TIME_OF_EVENT)
                             FROM OLD_LTE_CDR
                             WHERE DATE_TIME_OF_EVENT > (select (first_bundle.date_time_of_event)+1/24 from dual)
                             AND IN_SERVICE_RESULT_INDICATOR=26);
    select first_bundle.account_identifier ,first_bundle.top_up_profile_name
    ,FIRST_BUNDLE.date_time_of_event
    INTO MDN,TOPUP,START_DATE
    from dual;
    insert into consumed1 VALUES(X,topup,MDN,START_DATE,Y);
    end loop;
    COMMIT;
    end;

    > where account_identifier=(select first_bundle.account_identifier from dual)
    Why are you doing this?  It's a completely unnecessary subquery.
    Just do this:
    where account_identifier = first_bundle.account_identifier
    Same for all your other FROM DUAL subqueries.  Get rid of them.
    More importantly, don't use a cursor for loop.  Just write one big INSERT statement that does what you want.

  • Streamline query ? Taking too long

    First I wanted to say thanks to all in this forum, its been a huge help learning sql.
    Hoping someone can take a look at this query. It works but it takes a very long time to run.
    maybe there is a way to streamline it. right now its using one project number, but typically I would put in 60 or 70 project numbers here..
    select proj_id from project_master where status='A' and project_number IN(
    '502998'
    )))c,
    if someone knows a better way to run this please let me know , I will try anything. currently it takes about an hour to run it for 1 project number.
    select * from(
    select
    b.doc_folder_id,c.project_number,b.name,a.doc_file_name,a.rec_update_date,a.rec_create_date,d.rnk
    from
    select doc_id,proj_id, doc_file_name,rec_create_date,rec_update_date from document_master where doc_status ='A'
    and doc_file_extension like 'pdf' or doc_file_extension like 'jpg'
    or doc_file_extension like 'xls' or doc_file_extension like 'doc'
    or doc_file_extension like 'txt' or doc_file_extension like 'png'
    or doc_file_extension like 'tif' or doc_file_extension like 'ppt'
    or doc_file_extension like 'pps' or doc_file_extension like 'msg'
    ) a,
    (select * from doc_folder_master
    where upper(name) LIKE '%DAILY REPORTS%'
    OR upper(name) LIKE '%MANPOWER REPORTS%'
    OR upper(name) LIKE '%SITE PURCHASES%'
    OR upper(name) LIKE '%SETE EHS ISSUES%'
    OR upper(name) LIKE '%TURNOVER PACKAGES%'
    OR upper(name) LIKE '11.04.01 PAD%'
    OR upper(name) LIKE '%EDSR%'
    OR upper(name) LIKE '%COQ WORKFLOW%'
    and status='A'
    ) b,
    (select proj_id,project_number from project_master where proj_id IN (
    select proj_id from project_master where status='A' and project_number IN(
    '502998'
    )))c,
    (select child_doc_type,
    parent_doc_id,child_doc_id,to_char(rec_create_date,'mm/dd/yyyy hh24:mi:ss'),
    row_number() over (partition by parent_doc_id,child_doc_type order by rec_create_date desc) rnk
    from document_relations)d
    where a.proj_id=b.proj_id
    and c.proj_id=a.proj_id
    and c.proj_id=b.proj_id
    and d.parent_doc_id=b.doc_folder_id
    and a.doc_id=d.child_doc_id)
    where rnk <3
    thanks for any assistance.
    Edited by: Jay on Dec 29, 2010 12:08 PM

    Hi,
    Please, you might want to read this post:
    When your query takes too long ...
    Providing further information is key to obtaining quality answers.
    Now on to the actual subject:
    It seems you want some sort of top-n query. Depending on the cardinality and the data that you have, you probably would want to prune the rows from the DOCUMENT_RELATIONS table early, before joining to the other tables. This way you can avoid the database wasting effort of looking up matches on the other tables to only then discard those joined rows. You can do that by pushing the WHERE rnk < 3 predicate into the inline view.
    SELECT *
      FROM (SELECT b.doc_folder_id, c.project_number, b.name, a.doc_file_name, a.rec_update_date, a.rec_create_date, d.rnk
              FROM (SELECT doc_id, proj_id, doc_file_name, rec_create_date, rec_update_date
                      FROM document_master
                     WHERE doc_status = 'A'
                           AND doc_file_extension IN ('pdf', 'jpg', 'xls', 'doc', 'txt', 'png', 'tif', 'ppt', 'pps', 'msg')) a,
                   (SELECT *
                      FROM doc_folder_master
                     WHERE upper(NAME) LIKE '%DAILY REPORTS%'
                           OR upper(NAME) LIKE '%MANPOWER REPORTS%'
                           OR upper(NAME) LIKE '%SITE PURCHASES%'
                           OR upper(NAME) LIKE '%SETE EHS ISSUES%'
                           OR upper(NAME) LIKE '%TURNOVER PACKAGES%'
                           OR upper(NAME) LIKE '11.04.01 PAD%'
                           OR upper(NAME) LIKE '%EDSR%'
                           OR upper(NAME) LIKE '%COQ WORKFLOW%'
                           AND status = 'A') b,
                   (SELECT proj_id, project_number
                      FROM project_master
                     WHERE proj_id IN (SELECT proj_id
                                         FROM project_master
                                        WHERE status = 'A'
                                              AND project_number IN ('502998'))) c,
                   (SELECT *
                      FROM (SELECT child_doc_type,
                                   parent_doc_id,
                                   child_doc_id,
                                   to_char(rec_create_date, 'mm/dd/yyyy hh24:mi:ss'),
                                   row_number() over(PARTITION BY parent_doc_id, child_doc_type ORDER BY rec_create_date DESC) rnk
                              FROM document_relations)
                     WHERE rnk < 3) d
             WHERE a.proj_id = b.proj_id
                   AND c.proj_id = a.proj_id
                   AND c.proj_id = b.proj_id
                   AND d.parent_doc_id = b.doc_folder_id
                   AND a.doc_id = d.child_doc_id)Like Toon said, if not needed you should avoid the 2nd scan in the PROJECT_MASTER table.
    Perhaps you should check the possibility of creating a function-based index on the doc_folder_master table, with the upper(NAME) expression, to improve those Like conditions.
    Docs on Function-based Indexes:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16638/data_acc.htm#PFGRF94785

  • Oracle - Query taking too long (Materialized view)

    Hi,
    I am extracting billing informaiton and storing in 3 different tables... in order to show total billing (80 to 90 columns, 1 million rows per month), I've used a materialized view... I do not have indexes on 3 billing tables - do have 3 indexes on Materialized view...
    at the moment it's taking too long to query the data (running a query via toad fails and shows "Out of Memory" error message; runing a query via APEX though is providing results but taking way too long)...
    Please advice how to make the query efficient...

    tparvaiz,
    Is it possible when building your materialized view to summarize and consolidate the data?
    Out of a million rows, what would your typical user do with that amount data if they could retrieve it readily? The answer to this question may indicate if and how to summarize the data within the materialized view.
    Jeff
    Edited by: jwellsnh on Mar 25, 2010 7:02 AM

  • Deletion Query takes too long

    I have two tables with exactly the same structure. The table 1 gets data and one procedure reads that data and inserts them into another table (table2) for processing them. I have a delete query which is taking too long to execute.
    The query is as follows
    delete
    from events.temp_act a
    where a.chess_ts < (select max(chess_ts) from events.temp_act b
    where a.db_type = b.db_type
    and a.order_no = b.order_no
    and a.acv_no = b.acv_no
    There is a composite index in this table which is (db_type,order_no,acv_no)
    In my procedure, I drop and create the index for faster processing and also analyze the index.
    The above deletion query approximately deletes half the number of total records.
    There is no primary key in the table for the reason that there can be no unique record identifier.
    The query takes nearly 2 hours for deleting about 1100000 records.
    Is there a way to make this query run faster?

    What is the explain plan for this statement? Is the index even being used?
    Is the table analyzed as well as the index?
    Dropping/re-creating the index - not likely to help. I would leave this out.
    Have you tried other variations, like:
    delete
      from events.temp_act
    where (db_type, order_no, acv_vo, chess_ts)
           not in (select db_type, order_no, acv_vo, max(chess_ts)
                     from events.temp_act b
                    group by db_type, order_no, acv_vo);

  • Sql Query takes too long to enter into the first line

    Hi Friends,
      I am using SQLServer 2008. I am running the query for fetching the data from database. when i am running first time after executed the "DBCC FREEPROCCACHE" query for clear cache memory, it takes too long (7 to 9 second) to enter into first
    line of the stored procedure. After its enter into the first statement of the SP, its fetching the data within a second. I think there is no problem with Sqlquery.  Kindly let me know if you know the reason behind this.
    Sample Example:
    Create Sp Sp_Name
    as
     Begin
     print Getdate()
      Sql statements for fetching datas
     Print Getdate()
     End
    In the above example, there is no difference between first date and second date.
    Please help me to trouble shooting this problem.
    Thanks & Regards,
    Rajkumar.R

     i am running first time after executed the "DBCC FREEPROCCACHE" query for clear cache memory, it takes too long (7 to 9 second)
    Additional to Manoj: A
    DBCC FREEPROCCACHE clears the procedure cache, so all store procedure must be newly compilied on the first call.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Query designer takes too long to save a query

    Hi dear SDN friends.
    I´m working with query designer in BI 7 and sometimes it takes too long to save a query, about ten minutes. Sometimes it never ends saving and some other times it saves the same query in 1 minute.
    Can anybody please give an advice about this behavior of the query designer?
    We have recently update BI to sp18. In query designer I have sp5 revision 529
    Best regards,
    Karim Reyes

    Hello Karim,
    I would suggest testing this again in the latest Frontend Patch available (FEP 602).  In FEPs 600, 601, & 602 there were some performance and stability improvements made which may correct your issue.  If the issue persists, I would suggest then opening a Customer Message via Service Marketplace.
    It can be downloaded from:
        http://service.sap.com/swdc
    u2192Download
    u2192Support Packages and Patches
    u2192Entry by Application Group
    u2192SAP Frontend Components
    u2192BI ADDON FOR SAPGUI
    u2192 BI 7.0 ADDON FOR SAPGUI 7.10
    u2192 BI 7.0 ADDON FOR SAPGUI 7.10
    u2192Win32
    See SAP Note 1085218 for planned FEP releases.
    I hope that helps.
    Regards,
    Tanner Spaulding
    SAP NetWeaver RIG Americas, BI

  • Query running for too long

    Hi All,
    Can someone pls help me in finding how long will it take to execute the below query.
    I have a query that is taking too long to execute.
    SELECT   CPU_TIME/1000000/60 CPUTIME, ELAPSED_TIME/1000000/60 ELAPSEDTIME, PROGRAM_LINE#, OPTIMIZER_COST,
    USER_IO_WAIT_TIME/1000000/60 IOWAITTIME,  DISK_READS, DIRECT_WRITES, BUFFER_GETS, to_char(Q.SQL_FULLTEXT), OPTIMIZER_MODE,  SHARABLE_MEM, PERSISTENT_MEM, RUNTIME_MEM, SORTS, FETCHES, EXECUTIONS, END_OF_FETCH_COUNT, USERS_EXECUTING, LOADS,
    FIRST_LOAD_TIME,  INVALIDATIONS, PARSE_CALLS, APPLICATION_WAIT_TIME, CONCURRENCY_WAIT_TIME, CLUSTER_WAIT_TIME,
    PLSQL_EXEC_TIME, JAVA_EXEC_TIME, ROWS_PROCESSED, COMMAND_TYPE, PARSING_USER_ID, PARSING_SCHEMA_ID, PARSING_SCHEMA_NAME, OBJECT_STATUS
         FROM     v$session S, v$sqlarea Q
         WHERE    S.SQL_ADDRESS = Q.ADDRESS
         AND      s.username = 'SCHEMA_NAME'
         AND       s.osuser = 'OSUSER_NAME';I can see CPU_TIME increasing. Is there any way that I can find how lmuch more time will it take for the query to execute.
    The query creates a table that has a sub query and inner query.
    rgds
    saaz

    http://www.gplivna.eu/papers/v$session_longops.htm
    There is a dynamic performance view v$session_longops that is populated for many long running operations in Oracle. The primary criterion for any operation to appear in v$session_longops is to run more than 6 seconds. Although this isn’t the only criterion as well as not all operations that take more than 6 seconds are shown in this view. For example one can find hash joins in v$session_longops, but you won’t find there nested loop joins even if they are longer than 6 seconds and are joining very big data sets.

  • Query is taking too long to execute - contd

    I am unable to post the entire explain plan in one post as it exceeds maximum length.
    Please advise on how to post this.
    Previous post Link : Link: Query is taking too long to execute
    Regards,
    Sreekanth Munagala.
    Edited by: Sreekanth Munagala on Oct 27, 2009 8:31 AM
    Edited by: Sreekanth Munagala on Oct 27, 2009 8:34 AM

    Hi Tubby,
    Today i executed only the first query in the view and it took almost 2.5 hrs.
    Here is the explain plan for this query
    SQL> SET SERVEROUTPUT ON
    SQL> set linesize 200
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    | Id  | Operation                                        |  Name                         | Rows  | Bytes | Cost  |                                                                                     
    |   0 | SELECT STATEMENT                                 |                               |     1 |   766 |  2448 |                                                                                     
    |   1 |  TABLE ACCESS BY INDEX ROWID                     | PO_VENDORS                    |     1 |    13 |     3 |                                                                                     
    |*  2 |   INDEX UNIQUE SCAN                              | PO_VENDORS_U1                 |     1 |       |     2 |                                                                                     
    |   3 |  TABLE ACCESS BY INDEX ROWID                     | PO_VENDORS                    |     1 |    29 |     3 |                                                                                     
    |*  4 |   INDEX UNIQUE SCAN                              | PO_VENDORS_U1                 |     1 |       |     2 |                                                                                     
    |   5 |  VIEW                                            | POC_ASN_PICKUP_LOCATIONS_V    |     2 |  2426 |    17 |                                                                                     
    |   6 |   UNION-ALL                                      |                               |       |       |       |                                                                                     
    |   7 |    NESTED LOOPS                                  |                               |     1 |    85 |     4 |                                                                                     
    |   8 |     NESTED LOOPS                                 |                               |     1 |    78 |     4 |                                                                                     
    |*  9 |      TABLE ACCESS BY INDEX ROWID                 | PO_VENDOR_SITES_ALL           |     1 |    73 |     3 |                                                                                     
    |* 10 |       INDEX UNIQUE SCAN                          | PO_VENDOR_SITES_U2            |     1 |       |     2 |                                                                                     
    |* 11 |      INDEX UNIQUE SCAN                           | PO_VENDORS_U1                 |     1 |     5 |     1 |                                                                                     
    |* 12 |     INDEX UNIQUE SCAN                            | FND_TERRITORIES_TL_U1         |     1 |     7 |       |                                                                                     
    |  13 |    NESTED LOOPS                                  |                               |     1 |    91 |    13 |                                                                                     
    |  14 |     NESTED LOOPS                                 |                               |     1 |    84 |    13 |                                                                                     
    |  15 |      TABLE ACCESS BY INDEX ROWID                 | PO_VENDORS                    |     1 |    13 |     3 |                                                                                     
    |* 16 |       INDEX UNIQUE SCAN                          | PO_VENDORS_U1                 |     1 |       |     2 |                                                                                     
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    |* 17 |      TABLE ACCESS BY INDEX ROWID                 | FND_LOOKUP_VALUES             |     1 |    71 |    10 |                                                                                     
    |* 18 |       INDEX RANGE SCAN                           | FND_LOOKUP_VALUES_U2          |    13 |       |     2 |                                                                                     
    |* 19 |     INDEX UNIQUE SCAN                            | FND_TERRITORIES_TL_U1         |     1 |     7 |       |                                                                                     
    |* 20 |  COUNT STOPKEY                                   |                               |       |       |       |                                                                                     
    |  21 |   TABLE ACCESS BY INDEX ROWID                    | MTL_SYSTEM_ITEMS_B            |     8 |   136 |    12 |                                                                                     
    |* 22 |    INDEX RANGE SCAN                              | MTL_SYSTEM_ITEMS_B_U1         |     8 |       |     3 |                                                                                     
    |* 23 |  COUNT STOPKEY                                   |                               |       |       |       |                                                                                     
    |  24 |   TABLE ACCESS BY INDEX ROWID                    | MTL_SYSTEM_ITEMS_B            |     8 |   288 |    12 |                                                                                     
    |* 25 |    INDEX RANGE SCAN                              | MTL_SYSTEM_ITEMS_B_U1         |     8 |       |     3 |                                                                                     
    |  26 |  TABLE ACCESS BY INDEX ROWID                     | FND_TERRITORIES_TL            |     1 |    24 |     2 |                                                                                     
    |* 27 |   INDEX UNIQUE SCAN                              | FND_TERRITORIES_TL_U1         |     1 |       |     1 |                                                                                     
    |  28 |  NESTED LOOPS                                    |                               |     1 |    40 |     5 |                                                                                     
    |  29 |   TABLE ACCESS BY INDEX ROWID                    | HZ_CUST_ACCOUNTS              |     1 |    11 |     3 |                                                                                     
    |* 30 |    INDEX UNIQUE SCAN                             | HZ_CUST_ACCOUNTS_U1           |     1 |       |     2 |                                                                                     
    |  31 |   TABLE ACCESS BY INDEX ROWID                    | HZ_PARTIES                    |     1 |    29 |     2 |                                                                                     
    |* 32 |    INDEX UNIQUE SCAN                             | HZ_PARTIES_U1                 |     1 |       |     1 |                                                                                     
    |  33 |  TABLE ACCESS BY INDEX ROWID                     | FND_TERRITORIES_TL            |     1 |    24 |     2 |                                                                                     
    |* 34 |   INDEX UNIQUE SCAN                              | FND_TERRITORIES_TL_U1         |     1 |       |     1 |                                                                                     
    |  35 |  TABLE ACCESS BY INDEX ROWID                     | FND_TERRITORIES_TL            |     1 |    24 |     2 |                                                                                     
    |* 36 |   INDEX UNIQUE SCAN                              | FND_TERRITORIES_TL_U1         |     1 |       |     1 |                                                                                     
    |* 37 |  COUNT STOPKEY                                   |                               |       |       |       |                                                                                     
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    |* 38 |   TABLE ACCESS BY INDEX ROWID                    | ONTC_MTC_PROFORMA_HEADERS     |     1 |    21 |     3 |                                                                                     
    |* 39 |    INDEX RANGE SCAN                              | ONTC_MTC_PROFORMA_HEADERS_U2  |     1 |       |     2 |                                                                                     
    |  40 |  TABLE ACCESS BY INDEX ROWID                     | FND_TERRITORIES_TL            |     1 |    24 |     2 |                                                                                     
    |* 41 |   INDEX UNIQUE SCAN                              | FND_TERRITORIES_TL_U1         |     1 |       |     1 |                                                                                     
    |* 42 |  COUNT STOPKEY                                   |                               |       |       |       |                                                                                     
    |* 43 |   TABLE ACCESS BY INDEX ROWID                    | ONTC_MTC_PROFORMA_HEADERS     |     1 |    21 |     3 |                                                                                     
    |* 44 |    INDEX RANGE SCAN                              | ONTC_MTC_PROFORMA_HEADERS_U2  |     1 |       |     2 |                                                                                     
    |  45 |  SORT AGGREGATE                                  |                               |     1 |    39 |       |                                                                                     
    |  46 |   NESTED LOOPS OUTER                             |                               |     2 |    78 |  1828 |                                                                                     
    |* 47 |    TABLE ACCESS FULL                             | ONTC_MTC_PROFORMA_HEADERS     |     1 |    24 |  1825 |                                                                                     
    |  48 |    TABLE ACCESS BY INDEX ROWID                   | ONTC_MTC_PROFORMA_LINES       |     5 |    75 |     3 |                                                                                     
    |* 49 |     INDEX RANGE SCAN                             | ONTC_MTC_PROFORMA_LINES_PK    |    11 |       |     2 |                                                                                     
    |  50 |  NESTED LOOPS                                    |                               |     1 |   766 |  2448 |                                                                                     
    |  51 |   NESTED LOOPS                                   |                               |     1 |   761 |  2447 |                                                                                     
    |  52 |    NESTED LOOPS                                  |                               |     1 |   746 |  2445 |                                                                                     
    |  53 |     NESTED LOOPS                                 |                               |     1 |   694 |  2443 |                                                                                     
    |  54 |      NESTED LOOPS                                |                               |     1 |   682 |  2441 |                                                                                     
    |  55 |       NESTED LOOPS                               |                               |     1 |   671 |  2439 |                                                                                     
    |  56 |        NESTED LOOPS                              |                               |     1 |   612 |  2437 |                                                                                     
    |  57 |         NESTED LOOPS                             |                               |     1 |   600 |  2435 |                                                                                     
    |  58 |          NESTED LOOPS                            |                               |     1 |   575 |  2433 |                                                                                     
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    |  59 |           NESTED LOOPS                           |                               |     1 |   552 |  2431 |                                                                                     
    |  60 |            NESTED LOOPS                          |                               |     1 |   533 |  2429 |                                                                                     
    |  61 |             NESTED LOOPS                         |                               |     1 |   524 |  2428 |                                                                                     
    |  62 |              NESTED LOOPS                        |                               |     1 |   455 |  2427 |                                                                                     
    |  63 |               NESTED LOOPS                       |                               |     1 |   429 |  2426 |                                                                                     
    |  64 |                NESTED LOOPS                      |                               |     1 |   389 |  2424 |                                                                                     
    |  65 |                 NESTED LOOPS                     |                               |     1 |   368 |  2422 |                                                                                     
    |  66 |                  NESTED LOOPS                    |                               |     1 |   308 |  2421 |                                                                                     
    |  67 |                   NESTED LOOPS                   |                               |     1 |   281 |  2419 |                                                                                     
    |  68 |                    NESTED LOOPS                  |                               |     1 |   253 |  2418 |                                                                                     
    |  69 |                     NESTED LOOPS                 |                               |     1 |   214 |  2416 |                                                                                     
    |  70 |                      NESTED LOOPS                |                               |    39 |  7371 |  2338 |                                                                                     
    |* 71 |                       TABLE ACCESS FULL          | RCV_SHIPMENT_HEADERS          |    39 |  5070 |  2221 |                                                                                     
    |* 72 |                       TABLE ACCESS BY INDEX ROWID| RCV_SHIPMENT_LINES            |     1 |    59 |     3 |                                                                                     
    |* 73 |                        INDEX RANGE SCAN          | RCV_SHIPMENT_LINES_U2         |     1 |       |     2 |                                                                                     
    |* 74 |                      TABLE ACCESS BY INDEX ROWID | PO_LINES_ALL                  |     1 |    25 |     2 |                                                                                     
    |* 75 |                       INDEX UNIQUE SCAN          | PO_LINES_U1                   |     1 |       |     1 |                                                                                     
    |* 76 |                     TABLE ACCESS BY INDEX ROWID  | PO_LINE_LOCATIONS_ALL         |     1 |    39 |     2 |                                                                                     
    |* 77 |                      INDEX UNIQUE SCAN           | PO_LINE_LOCATIONS_U1          |     1 |       |     1 |                                                                                     
    |* 78 |                    TABLE ACCESS BY INDEX ROWID   | PO_HEADERS_ALL                |     1 |    28 |     1 |                                                                                     
    |* 79 |                     INDEX UNIQUE SCAN            | PO_HEADERS_U1                 |     1 |       |       |                                                                                     
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    |* 80 |                   TABLE ACCESS BY INDEX ROWID    | OE_ORDER_LINES_ALL            |     1 |    27 |     2 |                                                                                     
    |* 81 |                    INDEX UNIQUE SCAN             | OE_ORDER_LINES_U1             |     1 |       |     1 |                                                                                     
    |  82 |                  TABLE ACCESS BY INDEX ROWID     | OE_ORDER_HEADERS_ALL          |     1 |    60 |     1 |                                                                                     
    |* 83 |                   INDEX UNIQUE SCAN              | OE_ORDER_HEADERS_U1           |     1 |       |       |                                                                                     
    |* 84 |                 TABLE ACCESS BY INDEX ROWID      | HZ_CUST_SITE_USES_ALL         |     1 |    21 |     2 |                                                                                     
    |* 85 |                  INDEX UNIQUE SCAN               | HZ_CUST_SITE_USES_U1          |     1 |       |     1 |                                                                                     
    |* 86 |                TABLE ACCESS BY INDEX ROWID       | HZ_CUST_SITE_USES_ALL         |     1 |    40 |     2 |                                                                                     
    |* 87 |                 INDEX UNIQUE SCAN                | HZ_CUST_SITE_USES_U1          |     1 |       |     1 |                                                                                     
    |  88 |               TABLE ACCESS BY INDEX ROWID        | WSH_CARRIERS                  |     1 |    26 |     1 |                                                                                     
    |* 89 |                INDEX UNIQUE SCAN                 | WSH_CARRIERS_U2               |     1 |       |       |                                                                                     
    |* 90 |              TABLE ACCESS BY INDEX ROWID         | WSH_CARRIER_SERVICES          |     1 |    69 |     1 |                                                                                     
    |* 91 |               INDEX RANGE SCAN                   | WSH_CARRIER_SERVICES_N1       |     2 |       |       |                                                                                     
    |* 92 |             TABLE ACCESS BY INDEX ROWID          | WSH_ORG_CARRIER_SERVICES      |     1 |     9 |     1 |                                                                                     
    |* 93 |              INDEX RANGE SCAN                    | WSH_ORG_CARRIER_SERVICES_N1   |     1 |       |       |                                                                                     
    |  94 |            TABLE ACCESS BY INDEX ROWID           | HZ_CUST_ACCOUNTS              |     1 |    19 |     2 |                                                                                     
    |* 95 |             INDEX UNIQUE SCAN                    | HZ_CUST_ACCOUNTS_U1           |     1 |       |     1 |                                                                                     
    |* 96 |           TABLE ACCESS BY INDEX ROWID            | HZ_CUST_ACCT_SITES_ALL        |     1 |    23 |     2 |                                                                                     
    |* 97 |            INDEX UNIQUE SCAN                     | HZ_CUST_ACCT_SITES_U1         |     1 |       |     1 |                                                                                     
    |* 98 |          TABLE ACCESS BY INDEX ROWID             | HZ_CUST_ACCT_SITES_ALL        |     1 |    25 |     2 |                                                                                     
    |* 99 |           INDEX UNIQUE SCAN                      | HZ_CUST_ACCT_SITES_U1         |     1 |       |     1 |                                                                                     
    | 100 |         TABLE ACCESS BY INDEX ROWID              | HZ_PARTY_SITES                |     1 |    12 |     2 |                                                                                     
    PLAN_TABLE_OUTPUT                                                                                                                                                                                      
    |*101 |          INDEX UNIQUE SCAN                       | HZ_PARTY_SITES_U1             |     1 |       |     1 |                                                                                     
    | 102 |        TABLE ACCESS BY INDEX ROWID               | HZ_LOCATIONS                  |     1 |    59 |     2 |                                                                                     
    |*103 |         INDEX UNIQUE SCAN                        | HZ_LOCATIONS_U1               |     1 |       |     1 |                                                                                     
    |*104 |       INDEX RANGE SCAN                           | HZ_LOC_ASSIGNMENTS_N1         |     1 |    11 |     2 |                                                                                     
    | 105 |      TABLE ACCESS BY INDEX ROWID                 | HZ_PARTY_SITES                |     1 |    12 |     2 |                                                                                     
    |*106 |       INDEX UNIQUE SCAN                          | HZ_PARTY_SITES_U1             |     1 |       |     1 |                                                                                     
    | 107 |     TABLE ACCESS BY INDEX ROWID                  | HZ_LOCATIONS                  |     1 |    52 |     2 |                                                                                     
    |*108 |      INDEX UNIQUE SCAN                           | HZ_LOCATIONS_U1               |     1 |       |     1 |                                                                                     
    |*109 |    INDEX RANGE SCAN                              | HZ_LOC_ASSIGNMENTS_N1         |     1 |    15 |     2 |                                                                                     
    |*110 |   INDEX UNIQUE SCAN                              | HZ_PARTIES_U1                 |     1 |     5 |     1 |                                                                                     
    I will put the predicate information in another post.
    193 rows selected.
    SQL> spool offPlease suggest on how can we improve the performance.
    Regards,
    Sreekanth Munagala.

  • Query taking way too long

    Hello,
    Can somebody please help.
    I am wanting to change this query so that it does not take too long. How can I do it please?
    select count(*), t.tel_no, t.prospect_id, a.ACCOUNT_NO, a.account_title
    from tel_nos t, account a
    where t.tel_type = 'S'
    AND t.prospect_id = a.prospect_id
    AND SYSDATE BETWEEN t.start_date AND NVL(t.end_date, SYSDATE)
    group by t.tel_no, t.prospect_id, a.ACCOUNT_NO, a.account_title
    having count(*) > 1
    Thanks in advance.

    Tuning is a science not a parlour guessing game. It's hard for us to diagnose the problem you have here as you have given us almost no information. For instance, are you using rule based or cost based optimizer? How big are these two tables? What indexes do they have? What percentage of rows are you expecting the query to return?
    Tuning is such a big area that it's hard to know where to begin. I suggest you start at the Oracle docs. Chapters 1, 4 and 5 will set you going.
    http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76992/toc.htm
    Having said all that you may well find this runs faster:
    SELECT count(*), t.tel_no, t.prospect_id, a.account_no, a.account_title
    FROM   account a, tel_nos t
    WHERE  t.tel_type = 'S'
    AND    sysdate BETWEEN t.start_date AND nvl(t.end_date, sysdate)
    AND    t.prospect_id = a.prospect_id
    GROUP  BY t.tel_no, t.prospect_id, a.account_no, a.account_title
    HAVING count(*) > 1
    /I leave it to you to work out why (it's nothing to do with clearer layout).
    Cheers, APC

  • Query taking too long

    I am running a fairly complex query with several table joins
    and it is taking too long. What can I do to improve performance?
    Thanks.
    Frank

    Dan's first suggestion is key - if you are doing multiple
    table joins, you want to make sure your indexes are set up on your
    tables correctly. If you have access to the database, this should
    be your first step. Rationalize's stored procedure suggestion is
    also a great idea (again, if you have access to create and manage
    stored procedures on your DB).
    Other than than, most databases usually have some sort of SQL
    efficiency analysis tool. SQL server has one built into their Query
    Analyzer tool. I would recommend using something like that to
    streamline your SQL. Like Dan said, something as simple as the
    order of elements in your where clause might make a big
    difference.

Maybe you are looking for

  • CPU flag vmx missing after Oracle VM Server install

    Hi all, I'd like to know if anyone have found this issue too. A two weeks ago I installed Oracle VM Server on a Intel Core2Duo E8400 that have Virtualization feature and Enabled on BIOS, but when I installed OVM this feature dissapearing from /proc/c

  • How can I click a link to open a new tab without automatically switching to the new tab?

    I use Ixquick as my search engine. When the search result comes up, every time I click a link, Firefox creates a new tab and changes the focus from the search results page to the page for the link I clicked. I want to have a new tab created , but I w

  • Problems with Java Loading

    I have been encountering issues with my Dell laptop loaded with Windows 7 and the requirement to update Java. It continually asks to install the update and do so but, when I come across something in Java code, there is an error message. Any suggestio

  • Locking out one window when bringing up another.

    I have an application that has a GUI interface and that application calls another class that also brings up a window where the user enters some parameters. When the second window is displayed I would like to lock the user out of the 1st window so tha

  • AutoCapitalized in dsp tag lib

    Hi, I have a requirement, to make a text field auto capitalization to be disabled using the dsp tag lib, in normal html input type we have autocapitalize attribute. How to do this using dsp tag lib. Thanks,