Server is firing two queries for grandtotal ?

I have a report and added grand totals to it.
I checked the queries in session monitor before and after adding the grand total.
previously, single query was sent to database by the server.
but after adding grand totals, server is sending two queries to database and my report performance went down.
Please suggest how to avoid this.

Hi,
OBIEE wil always fire a seperate query for Grand total. This is expected behaviour. You should look at the other ways to improve the performance of report like putting some default filters so that OBIEE does not have to prform sum on huge data.
Regards,
Sandeep

Similar Messages

  • Difference between two queries for no client installed

    I have created a collection for all discovered computers with no client installed using the following query:
    select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.Client is null
    If I go to Monitoring -> Client Status -> Client Activity and click on the link next to the pie chart for no clients installed I get a completely different result and they neither query contains the same computers as each other.
    Anyone know what the exact query the link in the monitoring section is using and why the results between the two are completely different?
    If would expect them to match up or at the very least that my first query should be the source of truth.

    If I use:
    select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.Client is null OR SMS_R_System.Client = 0
    and use the same limiting collection as the built in monitoring query  "All Desktop and Server Clients" I actually get 0 results from the query.  If I use "All Systems" as the limiting collection I still only get the same results
    that I do with out also querying for "equals 0" as well.
    I read one article that said that "equals 0" actually shows you the clients had the CCM client but it was uninstalled where "is Null" returns systems that never had the CCM client.
    I don't know if this is accurate but it doesn't explain why a built in monitoring query would return inaccurate results.  It only returns a fraction of the non-client systems that the above query returns and as mentioned, the systems returned in one
    are not included in the other.

  • Requirement wherein I want to call two queries in parallel using ABAP Prg

    We are using RSCRM_BAPI to run a query in background and write the results to a table. We later read this table and create a file. I have a requirement u2013 wherein I want to call two queries in parallel using an ABAP program.
    For our discussion assume:
    1) Program : ZCALL_RCRMBAPI  is a program that calls RSCRM_BAPI in background and takes the query name as input
    2) Program: ZMAIN_PROGRAM  this is the main program
    The requirement is to call the ZCALL_RCRMBAPI in a loop. Also within the loop call it in parallel. Basically we have an ODS that stores ; FISCPER. So I call the two queries for a list of FISCPER.
    ZMAIN_PROGRAM - A program that reads a table (ODS ) in our case and call the two programs in a loop and both should run in parallel .
    Now if it was sequential u2013 it was easy u2013 I would just say
    Loop at L_T_FISCPER .
    Update Z_FISCPER with L_T_FISCPER-FISCPER u201C Assume Z_FISCPER is a Z table . The VARIABLE in the query Q1 and Q2 use a customer exit to read this table.
    A)       SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q1 and return .
    B)      SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q2 and return .
    Endloop .
    Question: How do I make these calls in parallel u2013 yet retain control in the main program?
    A)       SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q1 and return .
    B)      SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q2 and return .

    Instead of RSCRM BAPI you can use the RRW3_QUERY_VIEW_DATA function module for greater control over program execution...
    /people/arun.varadarajan/blog/2009/07/29/make-the-most-out-of-query-execution--part-1
    will give you pointers as to how this can be done...

  • Listener - Two Services for Each Instance

    Oracle 11r2g was installed on a Linux SO. Everything is working, but when I check the Listener Services I got this status:
    lsnrctl services
    Service "S060" has 1 instance(s).
    Instance "S060", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
    "DEDICATED" established:86 refused:0
    LOCAL SERVER
    Service "S060.domain" has 1 instance(s).
    Instance "S060", status READY, has 1 handler(s) for this service...
    Handler(s):
    "DEDICATED" established:1289 refused:0 state:ready
    LOCAL SERVER
    There are Two Services for Each Instance. Is it normal or do I have to check anything else?
    Thanks in advance.

    910492 wrote:
    Oracle 11r2g was installed on a Linux SO. Everything is working, but when I check the Listener Services I got this status:
    lsnrctl services
    Service "S060" has 1 instance(s).
    Instance "S060", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
    "DEDICATED" established:86 refused:0
    LOCAL SERVER
    Service "S060.domain" has 1 instance(s).
    Instance "S060", status READY, has 1 handler(s) for this service...
    Handler(s):
    "DEDICATED" established:1289 refused:0 state:ready
    LOCAL SERVER
    There are Two Services for Each Instance. Is it normal or do I have to check anything else?
    Thanks in advance.Pretty normal. The "unknown" is the static registration coming from the SID_LIST entry in the listener.ora file. The "ready" is the dynamic registration from the db instance itself.

  • Merging queries for different multiproviders

    Is there are a way to use the output of one query as an input parameter for another query and use the output from the second query in the report.
    My requirement is that the data which is to be displayed in the report is found in two different multiproviders and we cannot create any other multiprovider. I created two queries for the two multiproviders. One of the characteristic of the first query has to be an input parameter for the second query and the one of the Key figure output of the second query should be one of the column in the report. Can anyone please suggest a way for this?

    Hi,
    this is possible by taking a variable restriction on that characterstic in the second report. This variable should have a processing type equal to REPLACEMENTPATH and there you can specify the first query as the source for this variable.
    With rgds,
    Anil Kumar Sharma .P

  • ACE deployment with two interface for client side

    /* Style Definitions */
    table.MsoNormalTable
    {mso-style-name:"Table Normal";
    mso-tstyle-rowband-size:0;
    mso-tstyle-colband-size:0;
    mso-style-noshow:yes;
    mso-style-priority:99;
    mso-style-parent:"";
    mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
    mso-para-margin:0cm;
    mso-para-margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";
    mso-ascii-font-family:Calibri;
    mso-ascii-theme-font:minor-latin;
    mso-hansi-font-family:Calibri;
    mso-hansi-theme-font:minor-latin;
    mso-fareast-language:EN-US;}
    In a ACE router mode deployment, I have a single context configured with two interface for server side and two interface for client side. In this situation how can we meet the demands of customers arriving from both networks? How can the ACE handle the client request if we configure one default-gateway to each network?
    Regards,
    Egomes

    Enable "mac-sticky" comand under each client inteface.
    It will ensure that ACE sends the response to the MAC address from which the request to the VIP was recieved.
    For more details
    http://cisco.biz/en/US/docs/interfaces_modules/services_modules/ace/v3.00_A1/command/reference/if.html#wp1033275
    HTH
    Syed Iftekhar AHmed

  • Whats the difference between these two queries ? - for tuning purpose

    Whats the difference between these two queries ?
    I have huge amount of data for each table. its takeing such a long time (>5-6hrs).
    here whice one is fast / do we have any other option there apart from listed here....
    QUERY 1: 
      SELECT  --<< USING INDEX >>
          field1, field2, field3, sum( case when field4 in (1,2) then 1 when field4 in (3,4) then -1 else 0 end)
        FROM
          tab1 inner join tab2 on condition1 inner join tab3 on condition2 inner join tab4 on conditon3
        WHERE
         condition4..10 and
        GROUP BY
          field1, field2,field3
        HAVING
          sum( case when field4 in (1,2) then 1 when field4 in (3,4) then -1 else 0 end) <> 0;
    QUERY 2:
       SELECT  --<< USING INDEX >>
          field1, field2, field3, sum( decode(field4, 1, 1, 2, 1, 3, -1, 4, -1 ,0))
        FROM
          tab1, tab2, tab3, tab4
        WHERE
         condition1 and
         condition2 and
         condition3 and
         condition4..10
        GROUP BY
          field1, field2,field3
        HAVING
          sum( decode(field4, 1, 1, 2, 1, 3, -1, 4, -1 ,0)) <> 0;
    [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    My feeling here is that simply changing join syntax and case vs decode issues is not going to give any significant improvement in performance, and as Tubby points out, there is not a lot to go on. I think you are going to have to investigate things along the line of parallel query and index vs full table scans as well any number of performance tuning methods before you will see any significant gains. I would start with the Performance Manual as a start and then follow that up with the hard yards of query plans and stats.
    Alternatively, you could just set the gofast parameter to TRUE and everything will be all right.
    Andre

  • Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database"

    Hi, Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database" ?
    When I use Connect Object Explorer, the "Connect to Server" dialog box which pops up has only 4 selections in the Server Type Drop Down List. They are Database Engine, Analysis Services, Reporting Services & Integration Services. I have read
    somewhere that there should be a compact database option. but I do not see it.
    What I would like to do is use free form SQL Queries against the tables in "SQL Server Compact 4.0 Local Database" .
    Once I have validated these queries, then I will use them in my Visual Studio 2012 C#, ASP.NET application. I created the Local Database using Visual Studio 2012 for use by my application.
    Thank you for your help..
    diana4

    Hello,
    With SSMS 2005 we have had the Option to work with SQL CE database files, but not with higher Version of SSMS.
    You can use the free SQL CE Toolbax instead; see
    http://sqlcetoolbox.codeplex.com/
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Can I use same result set for two queries?

    Hi,
    Can I use the same result set for two queries?
    For example:
    ResultSet rs = null;
    rs = ps.executeQuery(query1);
    while (rs.next()) {
    rs = ps.executeQuery(query2);
    while (rs.next()) {
    Is it OK to use? or Is there any preformance issues?
    Appreciate your help.
    Thanks in advance.
    Prasad Vagolu

    Sure. You have a variable of ResultSet type. First you create a ResultSet and assign it to that variable. Then later you create another ResultSet and assign it to that same variable. Assigning an object reference to a variable takes essentially no time, and at any rate it isn't any faster to assign it to a different variable. Also, no matter whether you use one variable or two, you are still creating two ResultSets.
    However, you really should be closing your ResultSets after you finish using them. That's nothing to do with the assigning-to-a-variable question.

  • Plan hash value for two queries!

    Hi,
    DB : Oracle 11g (11.2.0.3.0)
    OS: RHEL 5
    I have two question:
    1. Can two queries have same plan hash value? I mean I have below two queries:
    SELECT /+ NO_MERGE */ MIN(payor.next_review_date)*
    * FROM payor*
    * WHERE payor.review_complete = 0*
    * AND payor.closing_date IS NULL*
    * AND payor.patient_key = 10;*
    and
    SELECT  MIN(payor.next_review_date)
    * FROM payor*
    * WHERE payor.review_complete = 0*
    * AND payor.closing_date IS NULL*
    * AND payor.patient_key = 10;*
    When I tried to review the execution plan for both queries, the plan hash value remain same. Does it mean that execution plan for both queries are same? If yes, then how Oracle understands or changes the execution plan based on hint. If no then what plan hash value represents?
    2. If the execution plan with hint and without hint is same except for a given query except no.of rows and bytes. Does it mean that query with less rows and bytes scanned is better?
    Thanks in advance
    -Onkar

    Hi,
    there are two different things. One is EXPLAIN PLAN, which is how the optimizer thinks the query will be executed. It contains some estimates of cost, cardinalities etc. There is also EXECUTION PLAN. It also contains all this information regarding the optimizer estimates, but on the top of that, it also contains information about actual I/O incurred, actual cardinalities, actual timings etc.
    So if a hint is changing optimizer estimates, but the plan stays the same, then impact on query's performance is zero.
    If the actual numbers are changing, this is probably also irrelevant to the hint (e.g. you can have less physical reads because more blocks are found in the buffer cache the second time you're running the query, or you less work because you don't have to parse the statement etc.).
    Actually, most of optimizer hints don't affect optimizer estimates; rather, they try to get the optimizer to use a certain access method or a certain join order etc. regardless of the cost. So you must be talking about such hints as cardinality, dynamic_sampling etc. If that's not the case -- please clarify, because this means that something wrong is going on here (e.g. an INDEX hint may work or it may fail to work, but if it fails, optimizer estimates shouldn't change).
    Best regards,
    Nikolay

  • DNS timeout and Name Server timeout between two DC's

    Hi All
    My clients have a brand new domain built for them, with two domain controllers at separate sites, and one site is having some issues.
    At one site (where DC2 is hosted), all users are having 5-10 minute log on delays - once in everything is running without issues. Site where DC1 is has zero issues - they run smoothly, get a nice quick login etc. All users are using redirected folders and
    all have the same GPO's applying to them.
    DC1 also has periodic issues communicating with DC2 - nslookup using DC2 gives "DNS request timed out. timeout was 2 seconds" on external AND internal queries, but then 5 minutes later will resolve perfectly. During the "DNS time out"
    period, trying to resolve DC2 as a Name Server also gives the error "A timeout occurred during validation".
    Not sure if these (slow logon and DNS/NameServer time out issues) issues are related but I am at a loss.
    Reverse lookup zones are fully created and populated, entries aren't randomly deleting themselves. Replication between both DC's is working fine, no errors and SYSVOL/NETLOGON are sharing fine from both DC's. Occassionally restarting the DNS server services
    on both servers will kick them back into talking - but only for around 30sec-1minute, after that they communicate periodically without problems and spend the rest of the time not resolving.
    Any ideas floating around, as I am at a loss here. We haven't been able to join more than a few test users to DC2's site for fear of them all calling every day due to long log on periods.

    Hi,
    Are you pointing each DC/DNS to the other one as primary dns in tcp/ip properties? Can you post a dcdiag /a /f:dcdiag.log from the DC2?
    Any warnings/errors in Application log on the client(s) facing issues after they get logged in ? Can you also confirm that users from site with DC2 are having DC at : set | find /I "LOGONSERVER" output?
    Hope it helps.
    Regards,
    Calin
    Hi Calin
    The DC's were originally pointing at each other for the primary but others prior to posting here suggested that was not best practice anymore and said they should be the other way around - in any case, either direction doesn't resolve the issues.
    The only application error the users are getting is :
    The winlogon notification subscriber <SessionEnv> was unavailable to handle a notification event.
    The winlogon notification subscriber <GPClient> took 84 second(s) to handle the notification event (Logon)
    DCDIAG of DC2 :
    Directory Server Diagnosis
    Performing initial setup:
    Trying to find home server...
    Home Server = CAB1-DC-V01
    * Identified AD Forest.
    Done gathering initial info.
    Doing initial required tests
    Testing server: AUS\NDC1-DC-V01
    Starting test: Connectivity
    ......................... NDC1-DC-V01 passed test Connectivity
    Testing server: AUS\CAB1-DC-V01
    Starting test: Connectivity
    ......................... CAB1-DC-V01 passed test Connectivity
    Doing primary tests
    Testing server: AUS\NDC1-DC-V01
    Starting test: Advertising
    ......................... NDC1-DC-V01 passed test Advertising
    Starting test: FrsEvent
    ......................... NDC1-DC-V01 passed test FrsEvent
    Starting test: DFSREvent
    ......................... NDC1-DC-V01 passed test DFSREvent
    Starting test: SysVolCheck
    ......................... NDC1-DC-V01 passed test SysVolCheck
    Starting test: KccEvent
    ......................... NDC1-DC-V01 passed test KccEvent
    Starting test: KnowsOfRoleHolders
    ......................... NDC1-DC-V01 passed test KnowsOfRoleHolders
    Starting test: MachineAccount
    ......................... NDC1-DC-V01 passed test MachineAccount
    Starting test: NCSecDesc
    ......................... NDC1-DC-V01 passed test NCSecDesc
    Starting test: NetLogons
    ......................... NDC1-DC-V01 passed test NetLogons
    Starting test: ObjectsReplicated
    ......................... NDC1-DC-V01 passed test ObjectsReplicated
    Starting test: Replications
    ......................... NDC1-DC-V01 passed test Replications
    Starting test: RidManager
    ......................... NDC1-DC-V01 passed test RidManager
    Starting test: Services
    ......................... NDC1-DC-V01 passed test Services
    Starting test: SystemLog
    A warning event occurred. EventID: 0x80000109
    Time Generated: 12/17/2014 08:25:05
    Event String:
    A pointer device did not report a valid unit of angular measurement.
    A warning event occurred. EventID: 0x80000101
    Time Generated: 12/17/2014 08:25:05
    Event String:
    A pointer device reported a bad angular physical range.
    A warning event occurred. EventID: 0x80000102
    Time Generated: 12/17/2014 08:25:05
    Event String:
    A pointer device reported a bad angular logical range.
    A warning event occurred. EventID: 0x80000109
    Time Generated: 12/17/2014 08:25:06
    Event String:
    A pointer device did not report a valid unit of angular measurement.
    A warning event occurred. EventID: 0x80000101
    Time Generated: 12/17/2014 08:25:06
    Event String:
    A pointer device reported a bad angular physical range.
    A warning event occurred. EventID: 0x80000102
    Time Generated: 12/17/2014 08:25:06
    Event String:
    A pointer device reported a bad angular logical range.
    A warning event occurred. EventID: 0x80000109
    Time Generated: 12/17/2014 08:47:55
    Event String:
    A pointer device did not report a valid unit of angular measurement.
    A warning event occurred. EventID: 0x80000101
    Time Generated: 12/17/2014 08:47:55
    Event String:
    A pointer device reported a bad angular physical range.
    A warning event occurred. EventID: 0x80000102
    Time Generated: 12/17/2014 08:47:55
    Event String:
    A pointer device reported a bad angular logical range.
    A warning event occurred. EventID: 0x80000109
    Time Generated: 12/17/2014 08:47:55
    Event String:
    A pointer device did not report a valid unit of angular measurement.
    A warning event occurred. EventID: 0x80000101
    Time Generated: 12/17/2014 08:47:55
    Event String:
    A pointer device reported a bad angular physical range.
    A warning event occurred. EventID: 0x80000102
    Time Generated: 12/17/2014 08:47:55
    Event String:
    A pointer device reported a bad angular logical range.
    A warning event occurred. EventID: 0x80000109
    Time Generated: 12/17/2014 08:47:55
    Event String:
    A pointer device did not report a valid unit of angular measurement.
    A warning event occurred. EventID: 0x80000101
    Time Generated: 12/17/2014 08:47:55
    Event String:
    A pointer device reported a bad angular physical range.
    A warning event occurred. EventID: 0x80000102
    Time Generated: 12/17/2014 08:47:55
    Event String:
    A pointer device reported a bad angular logical range.
    ......................... NDC1-DC-V01 failed test SystemLog
    Starting test: VerifyReferences
    ......................... NDC1-DC-V01 passed test VerifyReferences
    Testing server: AUS\CAB1-DC-V01
    Starting test: Advertising
    ......................... CAB1-DC-V01 passed test Advertising
    Starting test: FrsEvent
    ......................... CAB1-DC-V01 passed test FrsEvent
    Starting test: DFSREvent
    There are warning or error events within the last 24 hours after the
    SYSVOL has been shared. Failing SYSVOL replication problems may cause
    Group Policy problems.
    ......................... CAB1-DC-V01 passed test DFSREvent
    Starting test: SysVolCheck
    ......................... CAB1-DC-V01 passed test SysVolCheck
    Starting test: KccEvent
    ......................... CAB1-DC-V01 passed test KccEvent
    Starting test: KnowsOfRoleHolders
    ......................... CAB1-DC-V01 passed test KnowsOfRoleHolders
    Starting test: MachineAccount
    ......................... CAB1-DC-V01 passed test MachineAccount
    Starting test: NCSecDesc
    ......................... CAB1-DC-V01 passed test NCSecDesc
    Starting test: NetLogons
    ......................... CAB1-DC-V01 passed test NetLogons
    Starting test: ObjectsReplicated
    ......................... CAB1-DC-V01 passed test ObjectsReplicated
    Starting test: Replications
    ......................... CAB1-DC-V01 passed test Replications
    Starting test: RidManager
    ......................... CAB1-DC-V01 passed test RidManager
    Starting test: Services
    ......................... CAB1-DC-V01 passed test Services
    Starting test: SystemLog
    An error event occurred. EventID: 0x0000272C
    Time Generated: 12/17/2014 08:30:22
    Event String:
    DCOM was unable to communicate with the computer 139.130.4.4 using any of the configured protocols; requested by PID 1810 (C:\Windows\system32\dcdiag.exe).
    An error event occurred. EventID: 0x0000272C
    Time Generated: 12/17/2014 08:30:43
    Event String:
    DCOM was unable to communicate with the computer 203.50.2.71 using any of the configured protocols; requested by PID 1810 (C:\Windows\system32\dcdiag.exe).
    An error event occurred. EventID: 0x0000272C
    Time Generated: 12/17/2014 08:31:05
    Event String:
    DCOM was unable to communicate with the computer 8.8.4.4 using any of the configured protocols; requested by PID 1810 (C:\Windows\system32\dcdiag.exe).
    An error event occurred. EventID: 0x0000272C
    Time Generated: 12/17/2014 08:31:27
    Event String:
    DCOM was unable to communicate with the computer 8.8.8.8 using any of the configured protocols; requested by PID 1810 (C:\Windows\system32\dcdiag.exe).
    ......................... CAB1-DC-V01 failed test SystemLog
    Starting test: VerifyReferences
    ......................... CAB1-DC-V01 passed test VerifyReferences
    Running partition tests on : DomainDnsZones
    Starting test: CheckSDRefDom
    ......................... DomainDnsZones passed test CheckSDRefDom
    Starting test: CrossRefValidation
    ......................... DomainDnsZones passed test
    CrossRefValidation
    Running partition tests on : aus
    Starting test: CheckSDRefDom
    ......................... aus passed test CheckSDRefDom
    Starting test: CrossRefValidation
    ......................... aus passed test CrossRefValidation
    Running partition tests on : ForestDnsZones
    Starting test: CheckSDRefDom
    ......................... ForestDnsZones passed test CheckSDRefDom
    Starting test: CrossRefValidation
    ......................... ForestDnsZones passed test
    CrossRefValidation
    Running partition tests on : Schema
    Starting test: CheckSDRefDom
    ......................... Schema passed test CheckSDRefDom
    Starting test: CrossRefValidation
    ......................... Schema passed test CrossRefValidation
    Running partition tests on : Configuration
    Starting test: CheckSDRefDom
    ......................... Configuration passed test CheckSDRefDom
    Starting test: CrossRefValidation
    ......................... Configuration passed test CrossRefValidation
    Running enterprise tests on : swms.com
    Starting test: LocatorCheck
    ......................... swms.com passed test LocatorCheck
    Starting test: Intersite
    Doing intersite inbound replication test on site AUS:
    ......................... swms.com passed test Intersite
    SYSVOL is sharing OK, these errors are occurring when DC1 is performing backups and comes good a few seconds later)
    The DNS failures are not on the NIC of each server they are the forwarders for the server, not sure why they are failing as DNS lookup is running fine and the IP's are resolving correctly within the forwarders.
    set | find /I "LOGONSERVER"
    C:\Users\Christopher.McCartne>set | find /I "LOGONSERVER"
    LOGONSERVER=\\NDC1-DC-V01
    NDC1 = DC1
    CAB1 = DC2
    The users are logging onto NDC1 currently as I did switch around their DNS servers to have DC1 as their primary to test if this resolved the logon times. It didn't so I've switched them back and will re-run the check to see which server is the logonserver.

  • Why are two queries better than one

    I'm trying to help out our developers who are struggling with the performance of a very simple select statmenent that for some reason is exhibiting some very inexplicable results.
    I'll show the SQL as a single statement first.....
    select * from transaction1 t where t.hid in (select distinct h.hid from history1 h,filter1 f where h.fid = f.fid and f.match='value');
    transaction 1 has 250k records, history1 has about 100k as does filter1. We know generally the subselect will only return a total of half a dozen or less records (only 1 in our testing here).
    Running the above query takes around 7 seconds.
    Changing this to a with clause.....
    WITH a as (select distinct h.hid from history1 h,filter1 f where h.fid = f.fid and f.match='value') select * from transaction1 t where t,hid in (select a.hid from a);
    and the runtime drops to 3 seconds. But then re-running the first statement again also now takes 3 seconds (so I guess there's some caching going on there).
    Now what really puzzles is if we split this into two queries.....
    select distinct h.hid from history1 h,filter1 f where h.fid = f.fid and f.match='value';
    This takes .1 of a second,
    select * from transaction1 t where t.hid in (12345);
    And this takes .1 of a second.
    So why when run seperately are they so fast, yet combined they take so long. I'm a bit baffled by this. We've rewritten the same SQL in half a dozen different ways with the same result and also done the same thing with other tables as well. Is it an optimisation issue?

    Appologies for not following protocol, my first time posting on here.
    Oracle 10g clustered.
    We have limited access as it's a customers server, but the explain plan comes back as....
    PLAN_TABLE_OUTPUT
    Plan hash value: 898894568
    | Id  | Operation            | Name              | Rows  | Bytes | Cost (%CPU)|Time     |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT     |                   | 49553 |    37M|  7075   (2)|00:01:25 |
    |*  1 |  HASH JOIN RIGHT SEMI|                   | 49553 |    37M|  7075   (2)|00:01:25 |
    |   2 |   VIEW               | VW_NSO_1          | 26131 |   331K|   476   (4)|00:00:06 |
    |*  3 |    HASH JOIN         |                   | 26131 |   791K|   476   (4)|00:00:06 |
    PLAN_TABLE_OUTPUT
    |*  4 |     TABLE ACCESS FULL| FILTER1           | 26131 |   484K|   246   (4)|00:00:03 |
    |   5 |     TABLE ACCESS FULL| HISTORY1          |   104K|  1225K|   227   (3)|00:00:03 |
    |   6 |   TABLE ACCESS FULL  | TRANSACTION1      |   199K|   150M|  6593   (1)|00:01:20 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       1 - access("T"."TID"="$nso_col_1")
       3 - access("H"."HID"="F"."ID")
       4 - filter("F"."MATCH"='value')
    20 rows selectedI'll admit, I'm not completely clear on what I'm reading here, other than the fact there are some big differences in the timing values
    We don't have privaleges to run trace, so I'm a bit stuffed there as I'm on the clients site, however I will get my developers to try this on our local server.
    Edited by: user1410957 on 15-Sep-2009 06:14

  • Two entries for each archive log in v$archived_log

    Hi,
    I have noticied that there are two entries for each archive log. Why this is so...?
    I have fired following command.
    ==================
    set pages 300
    set lines 120
    ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
    SELECT sequence#, first_time, next_time
    FROM v$archived_log
    ORDER BY sequence#;
    ==================
    output is as follows.
    ==================
    1436 24-FEB-2012 00:04:09 24-FEB-2012 08:24:21
    1436 24-FEB-2012 00:04:09 24-FEB-2012 08:24:21
    1437 24-FEB-2012 08:24:21 24-FEB-2012 15:45:01
    1437 24-FEB-2012 08:24:21 24-FEB-2012 15:45:01
    1438 24-FEB-2012 15:45:01 24-FEB-2012 15:45:04
    1438 24-FEB-2012 15:45:01 24-FEB-2012 15:45:04
    1439 24-FEB-2012 15:45:04 24-FEB-2012 15:45:57
    1439 24-FEB-2012 15:45:04 24-FEB-2012 15:45:57
    1440 24-FEB-2012 15:45:57 24-FEB-2012 17:26:41
    1440 24-FEB-2012 15:45:57 24-FEB-2012 17:26:41
    1441 24-FEB-2012 17:26:41 24-FEB-2012 18:40:07
    1441 24-FEB-2012 17:26:41 24-FEB-2012 18:40:07
    1442 24-FEB-2012 18:40:07 24-FEB-2012 19:36:17
    1442 24-FEB-2012 18:40:07 24-FEB-2012 19:36:17
    1443 24-FEB-2012 19:36:17 24-FEB-2012 19:36:18
    1443 24-FEB-2012 19:36:17 24-FEB-2012 19:36:18
    ==================
    Regards
    DBA.

    I have noticied that there are two entries for each archive log. Why this is so...?Mseberg already mentioned.. little in detail as below
    Check for the name column in v$archived_log,
    One location refers to Local destination LOG_ARCHIVE_DEST_1
    Other location refers to your standby/DR location, But it will shows you only service name instead of full archive name.
    select dest_id,name from v$archived_log where name is not null and completion_time like '%24%FEB%'
       DEST_ID NAME
             1 +ORAARCHIVE/prod1/archivelogs/arch_0001_0671689302_0000240097.arc
             2 (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=sldb1srv)(POR
               T=9101)))(CONNECT_DATA=(SERVICE_NAME=prod_sldb1srv_XPT)(INSTANCE_N
               AME=prod1)(SERVER=dedicated)))Edited by: CKPT on Feb 24, 2012 8:26 PM

  • SQL queries for finding values in 4 different tables

    I need to have certain queries to find specific data in this table, this is just an example table, but I will use the same ideas for my actual website and database.
    customers (customerID: integer, fName: string, lName: string)
    items (itemID: integer, description: string, price: float)
    orders (orderID: integer, itemID: integer, aID: integer, customerID: integer, date: date)
    addresses (aID: integer, housenum: integer, streetName: string, town:string, state: string, zip:integer)
    Values I need to find are
     List the town, first name, and last name of any customer who has shipped an item to the same town as another customer.
    Return the average amount of money each customer spent in March of 2013. (Note that the answer will be a single number
    List the first and last names of all customers who have had the same item shipped to at least two different addresses.
    List the top two states that have generated the most total revenue and the revenue they generated
    I did try a few different queries, for #3 I tried 
    SELECT customers.fName,
    customers.lName,
    COUNT(orders.itemID) AS `total items with diff address >= 2`
    FROM customers
    JOIN (SELECT customerID,itemID,
    COUNT(DISTINCT aID) AS diff_address
    FROM orders
    GROUP BY orders.itemID
              HAVING diff_address >= 2
             ) AS orders
          ON orders.customerID = customers.customerID 
    but I only got 1 result, and I do not think thats correct.
    Thanks for the help and I appreciate you taking the time to help me

    Why not post the sample data + desired result? Always state what version you are using.
    SELECT lname,A.aID,COUNT(*) cnt  FROM customers C JOIN orders O ON c.Customerid=O.Customerid 
    JOIN address A  ON A.aID=O.aID
    GROUP BY lname,aID
    Sorry  cannot test it right now...
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Queries for Open Sales Order Lines and Open Purchase Order Lines

    Experts,
    Forgive me if these have been addressed elsewhere but I can't find them.  I'd like to create two queries to use as Alerts as follows:
    1.  Query of open lines in Sales Orders that are more than two weeks old
    2.  Query of open lines in Purchase Orders that are more than 2 days old
    Thanks in advance for your help.
    Steve

    Hi Steve,
    A couple of query templates you can use for your alerts are as follows:
    Purchase Orders
    SELECT T0.\[DocNum\], T0.\[DocDate\], T0.\[DocDueDate\], T0.\[CardCode\], T0.\[CardName\], T1.\[ItemCode\], T1.\[Dscription\], T1.\[Quantity\], T1.\[OpenQty\], T1.\[Price\] FROM OPOR T0  INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.\[DocDueDate\] < (getdate() -2) AND  T1.\[LineStatus\] = 'O'
    Sales Orders
    SELECT T0.\[DocNum\], T0.\[DocDate\], T0.\[DocDueDate\], T0.\[CardCode\], T0.\[CardName\], T1.\[ItemCode\], T1.\[Dscription\], T1.\[Quantity\], T1.\[OpenQty\], T1.\[Price\] FROM ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.\[DocDueDate\] < (getdate() -14) AND  T1.\[LineStatus\] = 'O'
    You can change the SELECT section to remove some of the columns or add extra columns if need be.  Once your happy with the query you can attach it to an alert and set the frequency.
    Regards,
    Adrian

Maybe you are looking for

  • Do I need an Airport card, too?

    I have a flat panel iMac without an airport card connected to the internet via Ethernet with a 2Wire router. I have an iBook with an airport card. So .... my iBook connects to my 2Wire network via airport, but I can't get on the Internet and even tho

  • Release strategy for sales docs.

    dear all, we have a process in sales ,that we create scheduling agreement or sales order .It will have to be released by 4 different people with  different levels .Once released documents should not be modified by anyone except amendment procedure. P

  • T410/T510 and Dual Displays

    I'm looking at the T410 or T510 for my wife for her business.  I wanted to try and set her up with dual displays (either the laptop LCD itself plus one display or two physical displays.  Is there anything I need to be aware of in regards to a dock so

  • HT2736 Now, I've reset my iPad and I can't use my account because it says my account isn't used in itune store.

    I've already reedeemed my itune account and used it. Now, I've reset my iPad and I can't use my account because it says my account isn't used in itune store. What's the problem and how can I solve it? Please.

  • SQL Developer 3.0 data modeler print-to-pdf not working

    I am working in Windows XP. I am running SQL Developer version 3.0.04, which now includes a full-featured version of the Data Modeler. I have run into a problem with this version, which did not occur in the stand-alone version of the Data Modeler. Wh