A better  query needed

DELETE FROM ACCOUNT_ASCTN WHERE LIST_ID = 3999 AND
ACCOUNT_ID IN (
SELECT ACCOUNT_ID FROM ACCOUNT_ASCTN WHERE
LIST_STATUS_CODE ='A'
AND LIST_ID =3999 MINUS (SELECT ACCOUNT_ID FROM WORKLIST_ACNT ));
as sometimes it takes around 40 minutes for a particular list id if there are too many records in the acount_asctn table.
I tried with exists but its only making it better by a few seconds .

Hi , I know NOT IN is not recommended. But there is no harm if you just checking the performance.
Any way you can use this also:
DELETE FROM ACCOUNT_ASCTN aa
WHERE LIST_ID = 3999
AND LIST_STATUS_CODE ='A'
AND acccount_id NOT EXISTS (SELECT NULL FROM WORKLIST_ACNT wa
WHERE aa.ACCOUNT_ASCTN=wa.ACCOUNT_ID );
And if WORKLIST_ACNT has a lot of records and there is an index on ACCOUNT_ID you can try this approach also.
DELETE FROM ACCOUNT_ASCTN aa
WHERE LIST_ID = 3999
AND LIST_STATUS_CODE ='A'
AND (SELECT count(wa.account_id) FROM WORKLIST_ACNT wa
WHERE aa.ACCOUNT_ASCTN=wa.ACCOUNT_ID ) = 0;
Also check is there index for LIST_ID and LIST_CODE_STATUS on ACCOUNT_ASCTN table.
Regards

Similar Messages

  • Help for efficient/better query

    DB Details:
    Oracle 11g R2 - 11.2.0.1
    CREATE TABLE workflow_routing_assoc
        wf_routing_assoc_id   NUMBER,                                 -- unique id
        routing_group_id      NUMBER,        -- common id for the four combination
        routing_rule_id       NUMBER, -- this column differnciates the information provided eg: date,day,month,year
        routing_rule_value    VARCHAR2 (50 BYTE), -- this column contains the information for the routing_rule_id(third column) eg: 01(date),wed(day),month(sep),year(2011)
        created_by            VARCHAR2 (50 BYTE),              --created user name
        created_date          timestamp (6),                        --created date
        modified_by           VARCHAR2 (50 BYTE),           -- modifying user name
        modified_date         timestamp (6)
    )                                                              --modified date
    INSERT INTO workflow_routing_assoc (wf_routing_assoc_id,
                                        routing_group_id,
                                        routing_rule_id,
                                        routing_rule_value)
      VALUES   (1,
                55,
                8,
                'test-example');
    INSERT INTO workflow_routing_assoc (wf_routing_assoc_id,
                                        routing_group_id,
                                        routing_rule_id,
                                        routing_rule_value)
      VALUES   (2,
                55,
                5,
                '12');
    INSERT INTO workflow_routing_assoc (wf_routing_assoc_id,
                                        routing_group_id,
                                        routing_rule_id,
                                        routing_rule_value)
      VALUES   (3,
                55,
                2,
                'sep');
    INSERT INTO workflow_routing_assoc (wf_routing_assoc_id,
                                        routing_group_id,
                                        routing_rule_id,
                                        routing_rule_value)
      VALUES   (4,
                55,
                9,
                '2010');
    COMMIT;
    -- NEED A BETTER QUERY INSTEAD OF THIS
    *SQL> SELECT   result0.routing_group_id*
      *2    FROM   (SELECT   routing_group_id, routing_rule_id*
      *3              FROM   workflow_routing_assoc*
      *4             WHERE   routing_rule_value = 'test-example') result0,*
      *5           (SELECT   routing_group_id, routing_rule_id*
      *6              FROM   workflow_routing_assoc*
      *7             WHERE   routing_rule_value = '12') result1,*
      *8           (SELECT   routing_group_id, routing_rule_id*
      *9              FROM   workflow_routing_assoc*
    *10             WHERE   routing_rule_value = 'sep') result2,*
    *11           (SELECT   routing_group_id, routing_rule_id*
    *12              FROM   workflow_routing_assoc*
    *13             WHERE   routing_rule_value = '2010') result3*
    *14   WHERE       result0.routing_rule_id = 8*
    *15           AND result1.routing_rule_id = 5*
    *16           AND result2.routing_rule_id = 2*
    *17           AND result3.routing_rule_id = 9*
    *18           AND result0.routing_group_id = result1.routing_group_id*
    *19           AND result1.routing_group_id = result2.routing_group_id*
    *20           AND result2.routing_group_id = result3.routing_group_id;*
    op:
    ROUTING_GROUP_ID
                  55Thanks in advance

    Hi,
    What's wrong with the solution in the other thread?
    Query simplification
    Point out where it's getting the wrong results, and explain how you get the right results in those places. Post some new sample data and results if necessary.

  • Query needed urgently.Pls help in this regard

    1.I need to display the details of employee no,name,image if at all an employee is having a photo attached with his profile and their count.
    I need to display the count and the same details for the employees having no photo too.
    I did with a query also.But I need some better Query for performance.I used per_images,per_all_people_f(per_people_f) for the above.Could u suggest me any query relating to this.And moreover,can u suggest any settings need to be done in rdf for the same image to display.
    2.I need to display the approved time sheets between 3 months period.But I used HXC_Timecard_Summary .But in that table thr is no date duration such as time period column.Its having only start time and stop time which will count only for one day and not for a particular duration.SO,could you suggest me the solution for the same.

    Sorry, all my crystal balls are on the blink.
    You couldn't have guarenteed that you won't get your questions answered any better than you have:
    1. Use of the word "Urgent" in your title. To us, your problems aren't any more urgent than anyone else's problems on the forum, and a great deal less urgent than our own problems are!
    2. You have provided zero information on your tables, data, etc in terms of what you're working with and what you want it to look like. You expect us to know your table and data structures in depth ... well, see my initial comment re. my crystal balls.
    3. You say you've come up with a solution for your first point, but haven't provided it, nor do you appear to have done any searching or anything else that makes me think that you're not expecting us to do your work for you.
    I suggest you edit your title to remove the word "urgent" and provide much more detail (table create statements, insert statements, etc) than you have.

  • Defining more parameters than a query needs

    Hi.
    When I run the following code, I get the error "ORA-01036: illegal variable name/number" .
    The problem is that I currently define more parameters than the query needs. Thats because I don't know how many bind variables the query uses, and I would not like to parse the query ...
    I don't understand why I have to define exactly the same number of parameters, and in the exact order ... It doesn't make sense. As bind variables have names, there should be no problem passing more parameters or parameters in a different order: the binding should be done by name...
    I'm currently using Oracle10g, ODP.NET and .NET Framework 2.0.
    I would appreciate any help ...
    Thank you.
    Ricardo Coimbras
    ===== BEGIN VB.NET CODE =====
    Sub Execute_Query(ByVal SqlString as String)
    Dim ObjCmd As OracleCommand
    Dim DataAdap As OracleDataAdapter
    Dim outDsCorpo As DataSet
    Dim Constroi_Conn_String_Oracle As String
    Dim mObjConnOracle As OracleConnection
    Constroi_Conn_String_Oracle = "User ID=uuu" & _
    ";Password=ppp" & _
    ";Data Source=bd" & _
    ";Pooling=false"
    mObjConnOracle = New OracleConnection(Constroi_Conn_String_Oracle)
    mObjConnOracle.Open()
    ObjCmd = mObjConnOracle.CreateCommand()
    ObjCmd.CommandType = CommandType.Text
    ObjCmd.CommandText = SqlString
    ObjCmd.Parameters.Add("p1", OracleDbType.Char, 3, "001", ParameterDirection.Input)
    ObjCmd.Parameters.Add("p2", OracleDbType.Char, 3, "001", ParameterDirection.Input)
    DataAdap = New OracleDataAdapter(ObjCmd)
    outDsCorpo = New DataSet()
    DataAdap.Fill(outDsCorpo)
    GridView1.DataSource = outDsCorpo
    GridView1.DataBind()
    DataAdap = Nothing
    ObjCmd = Nothing
    mObjConnOracle.Close()
    mObjConnOracle.Dispose()
    mObjConnOracle = Nothing
    End Sub
    Execute_Query "select * from map.t_mapa_def where mapa_def_cod = :p1 order by mapa_def_cod"
    ===== END VB.NET CODE =====

    Hi,
    BindByPosition is the default behavior as per the docs, and you can change that by setting cmd.BindByName=true which adds a little bit of extra overhead.
    That wont fix the error seen when binding a random number of parameters to the statement though. You need to bind the correct number and types of parameters.
    Greg

  • How much UNDO does a query need?

    It seems that due to a gigantic delete, I am running out of UNDO. How can I see exactly how much undo a query needs?
    Searching on the web, I found this:
    select sq.sql_text sql_text, t.USED_UREC Records, t.USED_UBLK Blocks, (t.USED_UBLK*8192/1024) KBytes from v$transaction t,
    v$session s,
    v$sql sq
    where t.addr = s.taddr
    and s.sql_id = sq.sql_id
    and s.username = 'blah'
    , which is fine, but it seems to be returning results for only running queries. In other words, when the delete query I am investigating is executed, the above select returns no rows. Is there a way to modify it to return also queries that have been executed?
    Any help is welcome.
    Message was edited by:
    user622271

    Hi,
    It seems that you need to make an outer join between v$sql and v$session views [s.sql_id = sq.sql_id(+)] ... For more information is if this [url http://forums.oracle.com/forums/thread.jspa?messageID=1756927&#1756927]thread can help you.
    Cheers
    Legatti

  • SQL query needed to identify cancelled invoice where distribution lines

    SQL query needed to identify cancelled invoice where distribution lines Debit is not equal Credit line item in particular
    Is there a way from back end FROM ap_invoice_distributions_all where we can find for the cancelled invoice where distribution lines Debit is not equal Credit line item
    Regards,
    Prakash Ranjan

    Hello Prakash
    Can you please see if this query helps you?
    SELECT i.invoice_id, i.invoice_amount, nvl(sum(d.amount),0)
    FROM ap_invoice_distributions_all d, ap_invoices_all i
    WHERE i.org_id = <you org_id>
    AND i.invoice_id = d.invoice_id
    AND d.line_type_lookup_code not in ('PREPAY')
    AND i.cancelled_date IS NOT NULL
    GROUP BY i.invoice_id, i.invoice_amount
    HAVING (i.invoice_amount <> nvl(sum(d.amount),0))
    ORDER BY i.invoice_id asc
    Octavio

  • Query needed

    Query to get list of employees having photo attached with their profile and query needed to extract the January to April timesheets approved in oracle on 6th May 2008

    sorry could not understand your question completely.
    I think following query should work, but I am not sure
    select *
    from hxc_time_building_blocks
    where start_time >= sysdate - 60
    and scope = 'APPLICATION_PERIOD'
    and trunc(date_from) = trunc(sysdate)
    and date_to = to_date('31-12-4712', 'DD-MM-YYYY')
    and approval_status = 'APPROVED';
    Change your date from sysdate to some other date. This query is not optimized so you need to tweak it a bit if it works at all.
    Any other OTL Expert on this

  • How to find which query need to tuned

    Hi ,
    How can i find , which query need to tuned . Is there any mechanism behind it?

    The mechanisms behind it are depending on your database version.
    For example:
    Oracle 9i has STATSPACK that helps you to identify possible problem queries.
    Oracle 10g has AWR - Automatic Workload Repository
    Oracle 11g has SPA - Database Replay SQL Performance Analyzer
    but there are many more tools/mechanisms...trace/tkprof for example.
    Go to http://tahiti.oracle.com and do a search on 'performance tuning guide', and pick the one that matches your (sofar unknown) database version, read a bit every now and then and see what tools are at your disposal and fit your requirement and situation.
    Besides the links that Blu already posted, searches on http://asktom.oracle.com also give lots of pointers and explanations regarding the (neverending) tuning process (at least: helped me tremendously in understanding the tuning process, the do's and dont's).
    Make sure you don't get CTD (Compulsive Tuning Disorder) from all this... ;)

  • Write better query

    I am using oracle 10gR1 on windows.
    SELECT hr.msis, hs.mc, c.in_no
    FROM hr_num hr, SYS_no cx
    WHERE cx.msis=hr.msis And
    hr.mc<>'MN'
    How can i increase performance of this query.Plz sugest me or write better query?
    Thanks

    enable "autotrace on" at sql*plus and then execute that query and paste the plan as well as well statistics of this query here.Also paste the total number of rows for hr_num and SYS_no table and paste the result count for the table hr_num column mc.
    make sure is yours query predicate accurate
    And
    hr.mc'MN'
    Khurram

  • Can't load up dates to iPhoto when I try it says 10.8.2 or better is needed I have that on my MAC what to do

    Can't load updates to iPhoto when I try it says 10.8.2 or better is needed. I have that, it was loaded by a tech at the genius bar in August.  How can i correct this?  Fried

    What version of iPhoto are you currenty running and what version do you want to update it to? Where are you trying to get the update from?
    OT

  • Query Jump with Navigation ( Sub query need to show same Navigation )

    Hi All.
       We have 4 BEx queries in our Dashboard Web Template and each table web items shows 10 rows and remaining with Scorll.
       For Printing ,we have created a query jump for each BEx Query ( same copy query) that shows all the rows detail.
       When i tried to jump from Orginial Dashboard ( From Specific table/Bex Query) with drill down <b>( Plant by Material )</b> , the jump query is not showing the same drill down but it showing the default rows <b>( Plant as per query rows</b>).
       SAP has suggested us its possible to do Query Jump with Navgiation that shows the same drill down path (navigation) in Sub Query as well.
       Am unable to find how to configure that , did search in OSS / Other Forumns But there were no postings on this.
       For me there is no Settings in RSBBS (or) SPRO and tried the Web Address Jump as well to pass the Drill Down Status (or) Navigation. May be iam not looking at right place. We are at 3.1x
       We found some limitations with SAP recommended web printing ( we dont need to discuss about that as per our requirement ), and our users like the Query Jump printing as which we working on now.
       Please inform if this can be possible, if so how.
    Thanks
    Martin Mouli

    Thanks for reply Bhanu.
    Its not like just Plant by Material.
    I would like to do my slicing & dicing on Navigational block with any combinations ( Customer by Plant by Material )
    When i do query jump from My Original Web Table , my jump query need to show the same drill down ( Customer by Plant by Material)but its showing only Material. ( Which is a default row in sub query)
    To show the same navigation in jump query as well, right now am doing drill down again in jump query as well. Its time waste to repeat the same drill down steps in sub query.
    By default my Jump Query has Material as row and We will show Plant & Customer on Demand (free characteristics)
    Please inform if more information required.
    Regards
    Martin Mouli

  • Monitoring via WMI - query needs a long time to get a result

    Hi experts!
    I am using Icinga (Nagios Fork) and a plugin called check_wmi_plus.pl (Perl Skript) which uses the wmic linux implementation.
    I have now multiple servers which needs very long to answer. I am using exactly the same command on the hosts. I give you an example here:
    Server-A:  WMI query needs ~70 Seconds, Ping Time is ~0.5-2.0 ms
    Server-B:  WMI query needs ~9 Seconds, Ping Time is ~90-120 ms
    I ran exactly the same command, from the same host, with the same user credentials and they are on the same domain.
    This behavior is not by the operting system because I have 2008r2 and 2003 servers which do both, need short and long time. They are all in different locations so there seems not to be a network issue. Hosts that are having the problems are 2008 hyper-v
    hosts but also 2003 file servers.. so I dont see any match here.
    I dont know how to go ahead, where to start the next troubleshooting steps?
    Is there any WMI log on the server I can monitor?
    Any help or ideas would be great! Thanks in advance!
    cheers, Duffkess

    this issue
    might related to the network issues, please check the Receive Side Scaling and
    the TCP Chimney registry settings. If TCP Chimney was enabled along with the
    RSS setting, WMI would fail.  <o:p></o:p>
    Meanwhile
    please test if the local basic WMI query also slow by
    Administrator account.<o:p></o:p>
    a. Run wbemtest, connect the namespace
    root\cimv2<o:p></o:p>
    b. Click Query… and enter query as: Select * from
    Win32_ComputerSystem. <o:p></o:p>
    c. Note down how many seconds does the query take.<o:p></o:p>
    Please also test if the remote basic WMI query is slow by
    Administrator account.<o:p></o:p>
    a. Run wbemtest, connect the namespace
    \\machinename\root\cimv2<o:p></o:p>
    b. Click Query… and enter query as: Select * from
    Win32_ComputerSystem. <o:p></o:p>
    c. Note down how many seconds does the query take.<o:p></o:p>
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • BEx query needs to count unique characteristic values

    Is there any way to build a query using BEx query designer to count the number of unique values of a characteristic.  For instance, my cube has detailed transactions for claim information.  Each claim number can have multiple products.  My query need to show the number of claims that exist for each product.  I don't want the detail of the claim number, just how many claims exist.
    Product          Gross Paid Loss        Claim Count
    Total Auto                $ 43,865.01              ?
    Total Property  $ 4,068,321.57              ?
    Not assigned                19,426

    Hi,
    Creat calculated  keyfigure with data functions Count value and save with technical name.
    Right click on that go to propertes, select count with exception aggregation - Claim Number,
    also use after aggregation and decimal places '0'.
    Regards
    Malyadri

  • A brand new query tool is out on beta, we need feedback, so you get a free copy

    We at Nob Hill Software are working on a new query tool:
    http://www.nobhillsoft.com/MarieAlix.aspx?HeardVia=ptut
    You can read all about it on the above web page, but basically, its a very ambitious project to create what we call 'the query tool to end all query tools': everything you ever wanted, desired, dreamed about in a query tool, and then some.
    For that, we need people who will download it, use it, tell us what they think, what's good and what's not, and what they would like to see in the future. This program has been going on since winter 2009, and so far we've made plenty of DB users happy - but we could always use more feedback. No catches, no tricks, we will never ask for money or anything - just to know what you want, so we can put it in. When the tool is finally out on production, all those who contributed will have it for free - for life.
    If you're interested, just download and start working. Then email us your feedback, which can be anything from a single sentence to entire pages.
    Contact us through the site if you have any questions!
    Thank You
    Nob Hill Software

    You at Knob Hill software are spammers.
    Rude people posting in violation of the Terms of Service agreement you signed when you got your right to post in this forum.
    Why do you think any of us would want to do business with a company that demonstrates a profound lack of professionalism
    and a lack of respect for those of us that use these forums?
    Something to think about eh?
    An apology would be the appropriate thing for your next, and last, post.

  • SQL query - Need your help

    Guys,
    I am struggling with this sql. Any better ways of writing this one ?
    SELECT entity_id, SUM (volume)
    FROM (SELECT ev.entity_id, NVL (SUM (ev.volume), 0) AS volume
    FROM entity_volume ev
    WHERE ev.entity_id IN
    (112764,
    112800,
    112878,
    112916,
    112974,
    113016,
    113061,
    113102,
    113130,
    113177,
    113224,
    113259,
    113287,
    113319,
    113361,
    113430,
    113465,
    113493,
    113536,
    113584,
    113620,
    113648,
    113691,
    113740,
    113808,
    113838,
    113878,
    113949,
    113986,
    114014,
    114057,
    114103,
    114141,
    114169,
    114211,
    114260,
    114299,
    114328,
    114865,
    114883,
    114903,
    114935,
    114955,
    114975,
    115031,
    115045,
    115062,
    115079,
    115101,
    115139,
    115156,
    115172,
    115192,
    115212,
    115232,
    115272,
    115286,
    115300,
    115317,
    115339,
    115360,
    115399,
    115434,
    115451,
    115469,
    115483,
    115521,
    116520,
    116660,
    122648,
    122676,
    122704,
    122732,
    122760,
    123045,
    123101,
    123157,
    123213,
    123269,
    126138,
    129461,
    129476,
    129477,
    129479,
    129480,
    129481,
    129483,
    129484,
    129485,
    130025,
    130028,
    130042,
    139650,
    139672,
    139694,
    139716,
    139739,
    139761,
    139784,
    139806,
    139829,
    139851,
    139896,
    139918,
    140120,
    140142,
    140160,
    140178,
    140196,
    140212,
    140461,
    141098,
    141114,
    141130,
    141173,
    141377,
    143040,
    143073,
    143106,
    143139,
    143172,
    143205,
    143240,
    143273,
    143306,
    143339,
    143372,
    143405,
    143440,
    143473,
    143506,
    143539,
    143572,
    143605,
    150444,
    150447,
    146425,
    150460,
    146656,
    146657,
    146658,
    146659,
    146660,
    146661,
    146662,
    146664,
    146666,
    146668,
    146669,
    146670,
    146671,
    146672,
    146673,
    146674,
    146675,
    146676,
    146677,
    146678,
    146679,
    150472,
    150483,
    149824,
    149823,
    149821,
    149865,
    149934,
    149869,
    149868,
    149935,
    148233,
    149936,
    148266,
    148299,
    149076,
    148332,
    148366,
    148399,
    148498,
    148531,
    148564,
    148597,
    149109,
    148663,
    148696,
    148795,
    148828,
    148861,
    148894,
    148928,
    148961,
    149176,
    149209,
    149276,
    149309,
    149373,
    149427,
    149460,
    149493,
    149527,
    149560,
    149593,
    149627,
    149660,
    149693,
    151010,
    151043,
    150942,
    150977,
    151078,
    151111,
    151144,
    151178,
    151211,
    151244,
    151281,
    151290,
    151299,
    151391,
    151424,
    151457,
    151491,
    151524,
    151557,
    151591,
    151624,
    151657,
    151689,
    151695,
    151705,
    151711,
    151713,
    151750,
    151798,
    151799,
    151800,
    152039,
    152040,
    152041,
    166039,
    188961,
    196776,
    1000324590,
    1000324347,
    1000323287,
    1000323307,
    1000323175,
    1000323197,
    1000323220,
    1000323242,
    1000323264,
    1000323051,
    1000323074,
    1000323091,
    1000323108,
    1000323130,
    1000322958,
    1000322981,
    1000323024,
    1000322840,
    1000322863,
    1000322890,
    1000322912,
    1000322935,
    1000322710,
    1000322763,
    1000322778,
    1000322799,
    1000322821,
    1000322600,
    1000322508,
    1000322531,
    1000322554,
    1000322577,
    1000322393,
    1000322416,
    1000322439,
    1000322462,
    1000322485,
    1000322289,
    1000322305,
    1000322348,
    1000322146,
    1000322168,
    1000322217,
    1000322241,
    1000322263,
    1000322007,
    1000322030,
    1000322053,
    1000322083,
    1000321912,
    1000321918,
    1000321934,
    1000321941,
    1000321960,
    1000321984,
    1000321814,
    1000321860,
    1000321698,
    1000321721,
    1000321744,
    1000321773,
    1000321789,
    1000321584,
    1000321606,
    1000321629,
    1000321675,
    1000321476,
    1000321541,
    1000321561,
    1000321385,
    1000321405,
    1000321427,
    1000321454,
    1000321270,
    1000321293,
    1000321316,
    1000321339,
    1000321363,
    1000321184,
    1000321201,
    1000321225,
    1000321247,
    1000321068,
    1000321091,
    1000321113,
    1000321135,
    1000321156,
    1000320797,
    1000320816,
    1000320843,
    1000320469,
    1000320491,
    1000316052,
    1000316068,
    1000316070,
    1000316085,
    1000315946,
    1000315967,
    1000315988,
    1000316010,
    1000316031,
    1000315847,
    1000315869,
    1000315890,
    1000315912,
    1000315927,
    1000315929,
    1000315931,
    1000315751,
    1000315773,
    1000315788,
    1000315805,
    1000315826,
    1000315641,
    1000315664,
    1000315687,
    1000315708,
    1000315730,
    1000315617,
    1000310823,
    1000310845,
    1000310869,
    1000310891,
    1000310915,
    1000310734,
    1000310755,
    1000310778,
    1000310802,
    1000310367,
    1000310337,
    1000310106,
    1000310127,
    1000310172,
    1000310003,
    1000293084,
    1000293087,
    1000337019,
    1000336998,
    1000337040,
    1000336351,
    1000336182,
    1000336222,
    1000336208,
    1000336233,
    1000336234,
    1000267169,
    1000267173,
    1000267177,
    1000267181,
    1000267185,
    1000267189,
    1000336075,
    1000336079,
    1000266375,
    1000336098,
    1000336115,
    1000266247,
    1000266311,
    1000266059,
    1000266123,
    1000265995,
    1000265739,
    1000265803,
    1000265675,
    1000265611,
    1000265356,
    1000265240,
    1000265112,
    1000265176,
    1000264905,
    1000335383,
    1000335385,
    1000334418,
    1000334419,
    1000334420,
    1000099932,
    1000101089,
    1000101467,
    1000101875,
    1000102304,
    1000104426,
    1000104850,
    1000233832,
    1000233896,
    1000233772,
    1000233117,
    1000233186,
    1000233052,
    1000232865,
    1000232868,
    1000232871,
    1000232862,
    1000232783,
    1000232786,
    1000232790,
    1000232793,
    1000232796,
    1000232799,
    1000232802,
    1000232805,
    1000232808,
    1000232811,
    1000232831,
    1000232834,
    1000232837,
    1000232840,
    1000232843,
    1000232846,
    1000232849,
    1000232852,
    1000232856,
    1000232859,
    1000127079,
    1000127499,
    1000127919,
    1000128339,
    1000128741,
    1000129221,
    1000129641,
    1000130040,
    1000130775,
    1000131195,
    1000131594,
    1000132014,
    1000132434,
    1000132854,
    1000133274,
    1000133694,
    1000134114,
    1000134534,
    1000134954,
    1000135374,
    1000135794,
    1000136214,
    1000136634,
    1000137054,
    1000137474,
    1000137894,
    1000138314,
    1000138734,
    1000139154,
    1000139574,
    1000139994,
    1000140414,
    1000140834,
    1000141254,
    1000141674,
    1000142094,
    1000142514,
    1000142934,
    1000143354,
    1000143774,
    1000144194,
    1000144614,
    1000145034,
    1000145454,
    1000145874,
    1000146294,
    1000146714,
    1000147134,
    1000149131,
    1000149511,
    1000149891,
    1000150271,
    1000150651,
    1000151031,
    1000152171,
    1000152551,
    1000152931,
    1000153311,
    1000153691,
    1000154071,
    1000154451,
    1000155211,
    1000155591,
    1000155971,
    1000156351,
    1000156731,
    1000157111,
    1000157491,
    1000157871,
    1000158251,
    1000158631,
    1000159011,
    1000159391,
    1000159771,
    1000160151,
    1000160531,
    1000160911,
    1000161291,
    1000161671,
    1000162051,
    1000162431,
    1000162811,
    1000163191,
    1000163571,
    1000163951,
    1000164331,
    1000164711,
    1000165091,
    1000165471,
    1000165851,
    1000166231,
    1000148751,
    1000170854,
    1000151791,
    1000172181,
    1000154831,
    1000177783,
    1000178581
    AND ev.period_id IN (
    SELECT period_id
    FROM period
    WHERE month_year < (SELECT start_date
    FROM entity_effectivity
    WHERE entity_id = ev.entity_id)
    OR month_year > (SELECT end_date
    FROM entity_effectivity
    WHERE entity_id = ev.entity_id))
    AND ev.volume_type = 'FC'
    AND ev.program_id = :1
    GROUP BY ev.entity_id)
    GROUP BY entity_id
    HAVING SUM (volume) > 0
    I am on 9.2.0.2 and explain plan is as below..
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=ALL_ROWS          1           147                     
    FILTER                                        
    SORT GROUP BY          1      20      147                     
    VIEW          13      260      143                     
    SORT GROUP BY          13      494      143                     
    FILTER                                        
    HASH JOIN          13      494      139                     
    PARTITION RANGE SINGLE                                   KEY     KEY
    INLIST ITERATOR                                        
    TABLE ACCESS BY LOCAL INDEX ROWID     ENTITY_VOLUME     137      3 K     136                KEY     KEY
    INDEX RANGE SCAN     ENTITY_VOLUME_IDX_001     137           30                KEY     KEY
    TABLE ACCESS FULL     PERIOD     318      4 K     2                     
    TABLE ACCESS FULL     ENTITY_EFFECTIVITY     1      15      33                     
    TABLE ACCESS FULL     ENTITY_EFFECTIVITY     1      15      33

    Guys,
    Thanks mate.. I tried all your suggestion and tried with many hints etc.. But the query doesn't seem to come back in less than 30 seconds. Business wants this one to return in 20 seconds where in it's currently taking 1:20 sec
    Any one there who could give me a better solution ? Let me know if you need anymore information on this :
    SELECT entity_id, SUM (volume)
    FROM (SELECT ev.entity_id, NVL (SUM (ev.volume), 0) AS volume
    FROM entity_volume ev, period p, entity_effectivity ee
    WHERE exists( select 'x' from entity_volume e where e.entity_id = ev.entity_id and entity_id in
    (112764,
    112800,
    112878,
    112916,
    112974,
    113016,
    113061,
    113102,
    113130,
    113177,
    113224,
    113259,
    113287,
    113319,
    113361,
    113430,
    113465,
    113493,
    113536,
    113584,
    113620,
    113648,
    113691,
    113740,
    113808,
    113838,
    113878,
    113949,
    113986,
    114014,
    114057,
    114103,
    114141,
    114169,
    114211,
    114260,
    114299,
    114328,
    114865,
    114883,
    114903,
    114935,
    114955,
    114975,
    115031,
    115045,
    115062,
    115079,
    115101,
    115139,
    115156,
    115172,
    115192,
    115212,
    115232,
    115272,
    115286,
    115300,
    115317,
    115339,
    115360,
    115399,
    115434,
    115451,
    115469,
    115483,
    115521,
    116520,
    116660,
    122648,
    122676,
    122704,
    122732,
    122760,
    123045,
    123101,
    123157,
    123213,
    123269,
    126138,
    129461,
    129476,
    129477,
    129479,
    129480,
    129481,
    129483,
    129484,
    129485,
    130025,
    130028,
    130042,
    139650,
    139672,
    139694,
    139716,
    139739,
    139761,
    139784,
    139806,
    139829,
    139851,
    139896,
    139918,
    140120,
    140142,
    140160,
    140178,
    140196,
    140212,
    140461,
    141098,
    141114,
    141130,
    141173,
    141377,
    143040,
    143073,
    143106,
    143139,
    143172,
    143205,
    143240,
    143273,
    143306,
    143339,
    143372,
    143405,
    143440,
    143473,
    143506,
    143539,
    143572,
    143605,
    150444,
    150447,
    146425,
    150460,
    146656,
    146657,
    146658,
    146659,
    146660,
    146661,
    146662,
    146664,
    146666,
    146668,
    146669,
    146670,
    146671,
    146672,
    146673,
    146674,
    146675,
    146676,
    146677,
    146678,
    146679,
    150472,
    150483,
    149824,
    149823,
    149821,
    149865,
    149934,
    149869,
    149868,
    149935,
    148233,
    149936,
    148266,
    148299,
    149076,
    148332,
    148366,
    148399,
    148498,
    148531,
    148564,
    148597,
    149109,
    148663,
    148696,
    148795,
    148828,
    148861,
    148894,
    148928,
    148961,
    149176,
    149209,
    149276,
    149309,
    149373,
    149427,
    149460,
    149493,
    149527,
    149560,
    149593,
    149627,
    149660,
    149693,
    151010,
    151043,
    150942,
    150977,
    151078,
    151111,
    151144,
    151178,
    151211,
    151244,
    151281,
    151290,
    151299,
    151391,
    151424,
    151457,
    151491,
    151524,
    151557,
    151591,
    151624,
    151657,
    151689,
    151695,
    151705,
    151711,
    151713,
    151750,
    151798,
    151799,
    151800,
    152039,
    152040,
    152041,
    166039,
    188961,
    196776,
    1000324590,
    1000324347,
    1000323287,
    1000323307,
    1000323175,
    1000323197,
    1000323220,
    1000323242,
    1000323264,
    1000323051,
    1000323074,
    1000323091,
    1000323108,
    1000323130,
    1000322958,
    1000322981,
    1000323024,
    1000322840,
    1000322863,
    1000322890,
    1000322912,
    1000322935,
    1000322710,
    1000322763,
    1000322778,
    1000322799,
    1000322821,
    1000322600,
    1000322508,
    1000322531,
    1000322554,
    1000322577,
    1000322393,
    1000322416,
    1000322439,
    1000322462,
    1000322485,
    1000322289,
    1000322305,
    1000322348,
    1000322146,
    1000322168,
    1000322217,
    1000322241,
    1000322263,
    1000322007,
    1000322030,
    1000322053,
    1000322083,
    1000321912,
    1000321918,
    1000321934,
    1000321941,
    1000321960,
    1000321984,
    1000321814,
    1000321860,
    1000321698,
    1000321721,
    1000321744,
    1000321773,
    1000321789,
    1000321584,
    1000321606,
    1000321629,
    1000321675,
    1000321476,
    1000321541,
    1000321561,
    1000321385,
    1000321405,
    1000321427,
    1000321454,
    1000321270,
    1000321293,
    1000321316,
    1000321339,
    1000321363,
    1000321184,
    1000321201,
    1000321225,
    1000321247,
    1000321068,
    1000321091,
    1000321113,
    1000321135,
    1000321156,
    1000320797,
    1000320816,
    1000320843,
    1000320469,
    1000320491,
    1000316052,
    1000316068,
    1000316070,
    1000316085,
    1000315946,
    1000315967,
    1000315988,
    1000316010,
    1000316031,
    1000315847,
    1000315869,
    1000315890,
    1000315912,
    1000315927,
    1000315929,
    1000315931,
    1000315751,
    1000315773,
    1000315788,
    1000315805,
    1000315826,
    1000315641,
    1000315664,
    1000315687,
    1000315708,
    1000315730,
    1000315617,
    1000310823,
    1000310845,
    1000310869,
    1000310891,
    1000310915,
    1000310734,
    1000310755,
    1000310778,
    1000310802,
    1000310367,
    1000310337,
    1000310106,
    1000310127,
    1000310172,
    1000310003,
    1000293084,
    1000293087,
    1000337019,
    1000336998,
    1000337040,
    1000336351,
    1000336182,
    1000336222,
    1000336208,
    1000336233,
    1000336234,
    1000267169,
    1000267173,
    1000267177,
    1000267181,
    1000267185,
    1000267189,
    1000336075,
    1000336079,
    1000266375,
    1000336098,
    1000336115,
    1000266247,
    1000266311,
    1000266059,
    1000266123,
    1000265995,
    1000265739,
    1000265803,
    1000265675,
    1000265611,
    1000265356,
    1000265240,
    1000265112,
    1000265176,
    1000264905,
    1000335383,
    1000335385,
    1000334418,
    1000334419,
    1000334420,
    1000099932,
    1000101089,
    1000101467,
    1000101875,
    1000102304,
    1000104426,
    1000104850,
    1000233832,
    1000233896,
    1000233772,
    1000233117,
    1000233186,
    1000233052,
    1000232865,
    1000232868,
    1000232871,
    1000232862,
    1000232783,
    1000232786,
    1000232790,
    1000232793,
    1000232796,
    1000232799,
    1000232802,
    1000232805,
    1000232808,
    1000232811,
    1000232831,
    1000232834,
    1000232837,
    1000232840,
    1000232843,
    1000232846,
    1000232849,
    1000232852,
    1000232856,
    1000232859,
    1000127079,
    1000127499,
    1000127919,
    1000128339,
    1000128741,
    1000129221,
    1000129641,
    1000130040,
    1000130775,
    1000131195,
    1000131594,
    1000132014,
    1000132434,
    1000132854,
    1000133274,
    1000133694,
    1000134114,
    1000134534,
    1000134954,
    1000135374,
    1000135794,
    1000136214,
    1000136634,
    1000137054,
    1000137474,
    1000137894,
    1000138314,
    1000138734,
    1000139154,
    1000139574,
    1000139994,
    1000140414,
    1000140834,
    1000141254,
    1000141674,
    1000142094,
    1000142514,
    1000142934,
    1000143354,
    1000143774,
    1000144194,
    1000144614,
    1000145034,
    1000145454,
    1000145874,
    1000146294,
    1000146714,
    1000147134,
    1000149131,
    1000149511,
    1000149891,
    1000150271,
    1000150651,
    1000151031,
    1000152171,
    1000152551,
    1000152931,
    1000153311,
    1000153691,
    1000154071,
    1000154451,
    1000155211,
    1000155591,
    1000155971,
    1000156351,
    1000156731,
    1000157111,
    1000157491,
    1000157871,
    1000158251,
    1000158631,
    1000159011,
    1000159391,
    1000159771,
    1000160151,
    1000160531,
    1000160911,
    1000161291,
    1000161671,
    1000162051,
    1000162431,
    1000162811,
    1000163191,
    1000163571,
    1000163951,
    1000164331,
    1000164711,
    1000165091,
    1000165471,
    1000165851,
    1000166231,
    1000148751,
    1000170854,
    1000151791,
    1000172181,
    1000154831,
    1000177783,
    1000178581 ))
    AND ev.period_id = p.period_id
         AND ev.entity_id = ee.entity_id
         AND (p.month_year < ee.start_date or p.month_year > ee.end_date)
    AND ev.volume_type = 'FC'
    AND ev.program_id = 1000000462
    GROUP BY ev.entity_id)
    GROUP BY entity_id
    HAVING SUM (volume) > 0

Maybe you are looking for

  • Can't view data in IT302 - Additional Actions

    Hi Gurus, I cannot view any data in IT302 using Ad Hoc Query. Correct infoset was set up which include Additional actions infotype. IT302 was also properly set up in t77S0> ADMIN-EVSUP set to 1. And in T529A all Actions set to be updated in IT302. Th

  • Satellite 2410-413: USB2 PCMCIA card doesn't work

    Good morning. It is my first time on a forum, and my English is poor. I have tried to install a PCMCIA card with 4 USB-2 ports (hw & sw) on my Satellite 2410-413 in order to use a DTV dongle (hw & sw). It will not work: The ports seem to be declared

  • OS X Delay over HDMI rougted through Xbox One (no delay using Windows)

    I have my Mac Mini (late 2012, OS X 10.8.5) connected via HDMI to my Xbox One, which is connected to my tv via HDMI. I have been experience a very annoying lag, especially noticeable when using my trackpad. There is a noticeable delay between my trac

  • Lightning to HDMI/& 30 pin stopped working since OS update

    Purchased lightning to HDMI & lightning 8 pin to 30-pine adapters & since I updated to 7.1.2 they don't work on my iPhone 5s or iPad Air. But my lightning to SD Card does work.  Anyone else?  Anyone with support?

  • LR4 resizes .dng when I dont want it to

    Exporting my .nef files to .dng after editing them see's them going from full size 4692x3108 to 1024x768. Why?? I can save as .tif ok no problem. Using win 7 and latest LR version 4. Any help appreciated.