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

Similar Messages

  • Installing OS X on a new hard drive taking way too long?

    I switched out my old 250 GB hard drive that shipped with my MacBook Pro for a new 640 GB WesternDigit drive. I'm trying to use a Mavericks installer USB to install on my newly formatted hard drive, but it's taking way too long - I mean, I left it going overnight (about 7.5 hours), and when I came down, it wasn't even half done. Is there anything I can do here? I'd like to use my laptop. Thank you very much for any suggestions.

    Do you have a internet connection? Even with a USB installer that if good and functioning properly you need an internet connection to Authenticate the install with your Apple ID.
    If your old drive is still functioning you can connect it to your Mac with a SATA to USB adapter and use the Recovery HD on that original drive to reinstall Mavericks on the new drive.
    If the drive is no longer functioning and you have no way of getting to the Apple internet download for Mavericks then you will need to start with an install of the original version of OS X that came on your Mac when new then update and or upgrade to Snow Leopard 10.6.8 and then use the Mac App Store to reinstall Mavericks. There is not other way to do this. So save yourself some time and trouble and start fresh.
    If your original drive is still functioning and it had Mavericks installed on it you can also CLONE that drive to the new one once you connect it to your mac with some type of SATA to USB adapter or enclosure.
    If the Mavericks USB installer you have was made from a Mac that came with Mavericks pre-installed on it that will not work on your Mac.

  • It's taking way too long for my messages to load.

    Starting on Tuesday this week (10/14) it is taking way too long for my messages to load from my Gmail account. Once the message finally shows up in the Inbox, it's taking up to 10-15 min for the message to load where I can actually view the message. I'm going to have to move to another email application if this can't be resolved which is very unfortunate as I've enjoyed using Thunderbird up until now.

    I guess I'm at least happy to know it's not just me. I've had to abandon Thunderbird for now. I guess I'll keep an eye out for future updates.

  • Firefox is taking way too long to load pages. I have a very fast internet connection but firefox takes forever to load websites. At first it worked fine and very fast but now very slow??

    firefox is taking way too long to load pages. I have a very fast internet connection but firefox takes forever to load websites. At first it worked fine and very fast but now very slow??

    Hi there!
    do you test other browsers?
    i suggest to make a clean install of newer version of Firefox like v8.0.

  • Taking way too long to iPhone for iOS 5

    Taking too long to sinc iPhone for ios5

    What it has to do is install the framworks and then reload all of your data onto the iPhone. It took me 2 hours to install on my iPad but it took 15 min for my iPhone

  • OSX installation (and reloading images) taking way too long

    Hi everyone.
    I've noticed a problem lately: installing OSX (either my original Tiger DVD or my new Leopard DVD) is taking way longer than it should. The same thing also happens when I try to revert back to an older disk image.
    I tried installing Leopard yesterday and it said it was going to take 5 hours. Initially I thought it was because the disk I was using was partitioned, so today I have wiped the disk completely, restored it to one partition, and disconnected all my external drives and all but the primary internal ones. That seems to have dropped the install time to 3 hours.
    The first thing I did yesterday was try to restore an older image of my Tiger installation. That one was about 60GB in size and, even after 8 hours, the installation had not predicted an actual remaining install time, but from the progress bar, it looked like it would be at least 2 days.
    Why in the world would this be happening and has anyone run into it before? All the system checks I ran the other day seemed to indicate things were fine. So am I missing something?
    Thanks.
    -N

    Check the S.M.A.R.T. status of the HDs.
    Run DU and repair the HDs if needed.
    It's also possible that your optical drive is dying and/or your Tiger CD and Leopard DVDs are dirty or scratched.
    A typical Leopard install takes under 1 hour. Anything over 2 indicates some major issues.

  • Slideshow Taking WAY too long to load

    I have a slideshow posted at
    http://olyrents.com/slideshow.htm
    My client is saying it takes too long to load, and I am
    finding that it is loading all of the photos first before you can
    scroll through and view them. It's just not functioning properly.
    I wonder if someone could look at the actionscript and give
    me any suggestions? Maybe there's something else going on?
    I have attached the script from the original fla file.
    Thanks!

    That adds up to somewhere in the realm of 5MB, which isn't
    going to be a quick load time, though it might be visually workable
    if you separate the loading from the viewing.
    One thing you might consider is doing away with the preloader
    visual. With 65 images being interupted by 65 preloader screens, it
    kinda defeats the potential aethetics of the images and may lead
    one to think it's taking a long time to load them as a result.

  • HT1689 It is taking way too long to download my purchase, what's going on?

    My tv program download is taking too long

    Your TV program may be huge ... like a gigabyte or so.  That could take a very long time to download, depending on your WiFi connection speed and quality.

  • Mail taking way too long to get to my iphone...Rogers network Toronto

    Today, on more than one occasion I sent an email from my yahoo account to my .mac account. The email arrived within 2 minutes. I was online the entire time to verify. My iphone, failed to be notified within 30 minutes!! In actual fact, i don;t know how long it would have taken to get the email. The only way I managed to retrieve the email on my iphone was to select the mail application on the iphone and select "inbox". This forces the software to check for mail....This isn't PUSH at all.
    Is anyone else experiencing this.?
    Thanks
    B

    the push services are only as good as the pusher I believe. I know my yahoo mail doesn't get pushed very well. Sometimes it's instant other times it's not. My girlfriend's email on a microsoft exchange server activesync is pushed pretty consistently. Given some of the hangups with the mobileme services, I'm not too surprised that the push isn't working great. It's really a mobilme issue I think, and I will let others with the service chime in with their experiences.

  • BUNDLE_EXECUTE TAKING WAY TOO LONG TIME. PLEASE HELP

    Hi Experts,
    Please see that after we ugrade our SEM 4 to SEM 6 along with BW 3.5 to BI 7, I am performing Post Upgrade Testing in Sandbox.
    In this process when I tried executing a Global Planning Sequence in Back Ground by Right Clicking the GPS I wish to run and selected Execute PS in Background Option.
    But when I am looking at it's status in Job overview, it is running for ever. I still wonder that how come it is taking so long time and I have no clue.
    The same GPS when I tried executing the ssame way in DEV and QA servers where the Upgrade is still not happened it is not taking more than 80 Seconds.
    So Kindly guide me through this issue. Highly appreciate your valuble inputs.
    Thanks and Regards,
    BIP

    Hi ,
    We are facing the same issue in our new parallel systems (SEM 3.2 to SEM 6 along with BW 3.1 to BI 7). Please let us know how you solved the issue.
    Our Planning Sequence has just one copy function.
    The same GPS when I tried executing in old systems in SEM 3.2 and BW 3.1, it is working fine.
    Any solution?
    Thanks,
    H

  • Min() taking way too long

    Hi,
    I have two databases, one with 2 million rows and another with 171 million rows. On both boxes when I do a max() it takes milliseconds for the result to return. There is an index on this column.
    But when I do a min, on the DB with 2 million its takes about 2-3 minutes and min on the other DB with 171 M it takes only a few milliseconds.
    The execution plan seems to be fine, the cost in 1 in both. The only difference is that the one taking most time has large number of physical reads. Could anyone let me know what's happening. Both the DB boxes are exactly the same in terms of configuration.
    Elapsed: 00:03:25.38
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=8)
    1 0 SORT (AGGREGATE)
    2 1 INDEX (FULL SCAN (MIN/MAX)) OF 'ST_AI' (NON-UN
    IQUE) (Cost=1 Card=2126583 Bytes=17012664)
    Statistics
    0 recursive calls
    0 db block gets
    341787 consistent gets
    341749 physical reads
    0 redo size
    382 bytes sent via SQL*Net to client
    503 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed
    Elapsed: 00:00:00.23
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=8)
    1 0 SORT (AGGREGATE)
    2 1 INDEX (FULL SCAN (MIN/MAX)) OF 'ST_AI' (NON-UN
    IQUE) (Cost=1 Card=171363076 Bytes=1370904608)
    Statistics
    0 recursive calls
    0 db block gets
    4 consistent gets
    0 physical reads
    0 redo size
    383 bytes sent via SQL*Net to client
    503 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed

    here it is
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.01 0 0 0 0
    Execute 1 0.00 0.02 0 0 0 0
    Fetch 2 0.00 198.26 341207 341245 0 1
    total 4 0.00 198.30 341207 341245 0 1
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 27
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.01 0 0 0 0
    Execute 2 0.00 0.03 0 0 0 0
    Fetch 2 0.00 198.26 341207 341245 0 1
    total 5 0.00 198.32 341207 341245 0 1
    Misses in library cache during parse: 1
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 0 0.00 0.00 0 0 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 0 0.00 0.00 0 0 0 0
    Misses in library cache during parse: 0
    2 user SQL statements in session.
    0 internal SQL statements in session.
    2 SQL statements in session.
    0 statements EXPLAINed in this session.
    Trace file: db_ora_24250.trc
    Trace file compatibility: 9.02.00
    Sort options: default

  • SELECT statement using XML data taking way too long.

    Hi all, I am using SQL Server 2005.
    I have an issue which I find hard to describe. The server that I am using contains two test databases which are (supposed to be) identical. They both have tables named EVENTS with identical fields. I am using XML data to query and update data to this table. 
    When I run the SELECT in one database, against the EVENTS table it takes a long time. The longest I've kept it running is 2:30 minutes. When I run it against the EVENTS table in the other database the results are almost instantaneous. I've created a test
    query to duplicate this behavior:
    declare @ValidXMLInput xmlset @ValidXMLInput = '<EVENTS>
    <EVENT EID="8077" EDATE="2014-07-20 10:15"
    USERID="GTJ789" LOCID="7016" STATE="0" />
    </EVENTS>'
    SELECT Col.value('@EID','VARCHAR(5)'),Col.value('@STATE','INT')
    FROM @ValidXMLInput.nodes('//EVENTS/EVENT') Tab(Col) 
    left join tblEvents on                   
     tblEvents.EvIdNum=Col.value('@EID','VARCHAR(5)') And
     tblEvents.EvDate=Col.value('@EDATE','DATETIME') And
      tblEvents.UserId=Col.value('@USERID','VARCHAR(8)') And
    tblEvents.EvLocId=Col.value('@LOCID','VARCHAR(8)') 
    where tblEvents.EvIdNum Is Null
    Basically, the above query returns all rows in the XML table that are not in the database table. The results are then passed on to other statements.The columns in the join are key fields for tblEvents and have a PK index for both tables (in each db).
    Now the issue that I am having. When I use an EID in the XML data of any other value (as presented in the example above), such as '3477' the query runs fast on both databases; however, when I specifically use an EID of '8077' then the query slows down to
    a point where it takes more than 2:30 minutes (after which I cancel the execution). This only happens with one of the databases.
    For testing purposes I've created an XML structure with only one item. Both tables have approximate 111 million records. One table contains about 900K records with an EID of 8077. The other table contains about 930K records with this EID. There aren't many
    differences in the data. The records with the EID of 8077 (the slow one) are for different dates, users and locations. I should also mention that although the data presented here for EID consists of number, provisions exist where the number may be prefixed
    by a letter; hence the varchar designation.
    My question to you all is: How can I start troubleshooting this issue? Should I be looking at indexes?
    I had some doubt about this because the query is fast for other EIDs. Why would it get "stuck" with this particular one?
    Any troubleshooting advice is welcomed. Thanks! Saga
    Insanity is the prelude to discovery

    Some thoughts:
    Is there a hardware difference between the two databases ? E.g. are they on the same disk (array) ?
    Is there anything else running on your server besides your SQL instance ?
    Do you see spikes in I/O, CPU or both ?
    Maybe there is locking on one DB that's not happening in the other.
    You should check indexes and statistics plus compare estimated execution plan between the two DBs.
    Also check this links:
    http://technet.microsoft.com/en-us/library/ms345118%28v=sql.90%29.aspx
    http://technet.microsoft.com/en-us/library/ms345115%28v=sql.90%29.aspx

  • Updating 3GS from 3.1.2 to 6.1.3 taking way too long. Is there a better and faster way?

    How long does it take to update an original 3GS to 6.1.3? I followed the iTune instructions and it has been updating for hours already. Is there a better and faster way to do this?

    SO if I want to represent the London Underground
    network as a Graph how would I be able to do it?By writing classes of your own or using some one else's. I don't think that the collections framework has out-of-the-box support for graphs.... So try google first.
    The implementation details depend on the API you are going to use, of course...
    from A to B 5 min
    from B to C 4 min
    from A to C 9 min
    this information is redundant, the third info should be omitted. <nit-picking>
    No it's not - What if there's a special, more direct route from A to C? Also, getting from A to B to C will usually take more time than the time from A to B plus the time from B to C. The trains have to stop at B, don't they?
    </nit-picking>
    Maybe this approach is more complex, but it solves the problem Have I understood correctly - isn't what you describe just another way to implement a graph?

  • Shuffle taking way too long to sync

    after updating to itunes 8.o, all of the three shuffles that use that itunes library take forever to sync-even one song or podcast. what happened?? does anyone know how to fix this??

    Even though the Shuffle is listed as USB 2.0 compatible it only seems to sync at USB 1.1 speeds. I've had a nano and a shuffle and the nano syncs WAY faster than shuffle (no conversion to 128kbps AAC is taking place)
    Message was edited by: ajstahl

  • OS X Mountain Lion...taking way too long

    I purchased OS X Mountain Lion for my iMac.  iMac meets all the requirements MAC OS X 10.7.4.  It's been 22 hours and it isn't doing anything, sitting at 1.86 GB of 4.37 GB.  Why is the download taking so long?  Is there something else I should be doing? 

    Thank you for your reply...I do believe the WiFi connection in our neighborhood could be the factor here...congestion.
    Browsing has never been an issue...but downloading something this large obviously is.
    I have paused the download and resumed...since I posted earlier, it is now at 2.22 GB of 4.37 GB ... moving VERY slowly. 
    Not sure what to do at this point...I will call the support line during wrkg hrs.  See if they can cancel my online pymt and I'm assuming I can purchase the OS X Mountain Lion at Best Buy???
    The neighborhood is waking up soon...and more congestion will be interfering soon.

Maybe you are looking for

  • Can I use my mid 2011 iMac with an Xbox 360?

    Hello all, I have been unable to find a definative answer to this question so thought it best to ask here. Question being can I connect an Xbox 360 to my mid 2011 21.5 iMac and use it as a monitor for gaming? If this is possible, could you tell me ho

  • New itunes wont recognize my ipod

    i few days ago my ipod ran out of battery so i plugged it into the wall charger. the apple logo came up for a long time and when it went away all my songs were gone! so i plugged it into my labtop and itunes told me to update so i installed the new i

  • Form doesn't show -- HZ_CUST_ACCOUNT_ROLE_V2PUB.create_role_responsibility

    Hi All, Created Role responsibilities using HZ_CUST_ACCOUNT_ROLE_V2PUB.create_role_responsibility. API returned responsibility_id and I could check record in HZ_ROLE_RESPONSIBULITY table. But when I view it from Contact Roles screen, No value but If

  • Transfering AP, AR values from FI to PCA

    Hi, I have to activate PCA for my client after the system has gone live. I am planning to transfer the previous data through 9KE0 and after that the online transfer would be activated. But for AP & AR balances when I am trying to run 1KEK in the deve

  • Fiori Client - How to view the Log file

    Hi, on my Android phone the fiori client version 1.1.3 behaves awkward. When I want to start an app from the lauchpad the whole client app crashes. The android app just terminates. How can I access the logfile? The Fiori Client user Guide says I can