Why is the select Count too slow

I am doing the following select count and calling it from my JSP to get the total number of records... why is it so slow...
select count(*)
from
(select distinct o.receive_id, o.name, o.address
from order o, item i
where o.id = i.id
and o.status = 2 and i.status = 0)

If the data in the table that you are referring to in the query gets refreshed very often and your high water mark on your table not reset, then this query always runs longer. While deleting data in the table, use 'TRUNCATE' rather than 'DELETE' in your data queries. that would help reset the high water mark and your count() queries will run very very fast.

Similar Messages

  • Why is the Tick Count function slow when used with a .dll but fine with normal lab view code?

    when using the Tick Count millisecond timer with a .dll I've written in C, I'm getting some odd timing issues.
    When I code the function I want (I'll explain it below in case it helps) in LV and run it as a subVI, feeding it the Tick count as an argument, the function runs quickly, but not quite as quickly as I would like. When I feed this same subVI just an integer constant rather than the Tick Count, it takes about the same amount of time, maybe a tiny bit more on average.
    When I bring in my function from a .dll, however, I start to run into problems. When I feed my function an integer constant, it is much faster than my subVI written in LV. When I feel my .dll the Tick Count, however, it slows down tremendously. I'm including a table with the times below:
                 |  Clock   |   Constant   |
    SubVi:   | 450ms  |  465ms       |
    .dll         | 4900ms|  75ms         |
    This is running the function 100,000 times. The function basically shifts the contents of a 2-dimensional array one place. For this function, it probably won't be a huge deal for me, but I plan on moving some of my other code out of LV and into C to speed it up, so I'd really like to figure this out.
    Thanks,
    Aaron

    Hi Aaron,
    Thanks for posting the code -- that made things a lot clearer for me. I believe I know what's going on here, and the good news is that it's easy to correct! (You shouldn't apologize for this though, as even an experienced LabVIEW programmer could run into a similar situation.) Let me explain...
    When you set your Call Library Function Node to run in the UI Thread you're telling LabVIEW that your DLL is not Thread-safe -- this means that under no circumstances should the DLL be called from more than one place at a time. Since LabVIEW itself is inherently multithreaded the way to work with a "thread-unsafe" DLL is to run it in a dedicated thread -- in this case, the UI thread. This safety comes at a price, however, as your program will have to constantly thread-swap to call the DLL and then execute block diagram code. This thread-swapping can come with a performance hit, which is what you're seeing in your application.
    The reason your "MSTick fine behavior.vi" works is that it isn't swapping threads with each iteration of the for loop -- same with the "MSTick bad behavior.vi" without the Tick Count function. When you introduce the Tick Count Function in the for loop, LabVIEW now has to swap threads every single iteration -- this is where your performance issues originate. In fact, you could reproduce the same behavior with any function (not just TIck Count) or any DLL. You could even make your "MSTick fine behavior.vi" misbehave by placing a control property node in the for loop. (Property nodes are also executed in the UI thread).
    So what's the solution? If your DLL is thread-safe, configure the call library function node to be "reentrant." You should see a pretty drastic reduction in the amount of time it takes your code to execute. In general, you can tell if your DLL is thread-safe when:
    The code is thread safe when it does not store any global data, such as global variables, files on disk, and so on.
    The code is thread safe when it does not access any hardware. In other words, the code does not contain register-level programming.
    The code is thread safe when it does not make any calls to any functions, shared libraries, or drivers that are not thread safe.
    The code is thread safe when it uses semaphores or mutexes to protect access to global resources.
    The code is thread safe when it is called by only one non-reentrant VI.
    There are also a few documents on the website that you may want to take a look at, if you want some more details on this:
    Configuring the Call Library Function Node
    An Overview of Accessing DLLs or Shared Libraries from LabVIEW
    VI Execution Speed
    I hope this helps clear-up some confusion -- best of luck with your application!
    Charlie S.
    Visit ni.com/gettingstarted for step-by-step help in setting up your system

  • I'm getting "the disk is too slow (prepare)" message

    I'm getting "the disk is too slow (prepare)" message when trying to do literally anything in garageband right now, even with all other programs shut down, correct energy saver settings, and only one audio track in garageband.
    Everything else on my macbook pro is running fine, iMovie, Safari, etc... so it seems like a garageband problem to me. I updated garageband, have reset computer multiple times, I don't know what else to do... it feels like garageband is keeping all of my recent projects open in the background at once, but when I check my windows, that is apparently not the case.  Any help?

    Anyone have any ideas to help?

  • Why is the itunes download so slow

    why is the itunes download so slow - I am trying to download itunes update to recognize my new ipod touch 5th generation and my pc will not even show it in itunes, in trying to download the update the speeds are so slow that it is estimating download time in days.  I have stopped and started the apple in services, but it is still unrecognized.

    you know very well it has nothing to do with itunes or the modem/router.  apple servers are very very slow and its an absolute disgrace.
    you can download from third party servers at twice the speeds (at your own risk)
    Apple is the second largest company in the world and they treat customners in this way

  • Why is the wi-fi so slow??

    Why is the wi-fi so slow on the time capsule??? Brand new bought last week? help? running about 13 devices on more than one network. Help please..

    Is it slow compared to other devices.. ??
    Give numbers.. cannot operate from general comments.
    Is this 2.4ghz.. are you splitting the load over 2.4ghz and 5ghz??
    Have you tried using SMB names.. short no spaces pure alphanumeric, with different name for 5ghz.
    Lock the wireless channel for 2.4ghz and test 1, 6, 11 in turn.
    Using WPA2 personal security only.. with 8-12 character passkey.. pure alphanumeric of course.

  • Why is the word count different when I use word count from the tools menu to the number at the bottom of my mac word document

    Why is the word count different when I use word count from the tools menu to the number at the bottom of my mac word document

    This forum is for Apple's defunct office suite 'AppleWorks' - since the word count is not in the places you mention I assume you are talking about Microsoft Word? Though it's just possible someone in this forum might also use Word and know the answer, you would stand a higher chance of getting an answer in Microsoft's own forums. You could also try asking in the forum applicable to your operating system - Lion, Mavericks or whatever - on the reasonably chance of finding someone familiar with Word.

  • Why is the On Demand so slow to respond

    Title says it all
    Why is the On Demand so slow to respond?
    You have very fast Internet but extremely On Demand Programming Why is that?
    Fix it or ill have to go back to Road Runner. My wife runs a Preschool/Daycare and needs Fast On Demand programming because she's very busy with the kids.
    She allows them to watch some of the children's programming if they did well in the class work but she doesn't have time to wait for the EXTREMELY SLOW Response.

    Memory leakage causes it to run slow. One way to easily fix this is to reboot the box. It will automatically reallocate memory. To reboot, simply unplug power cord for 1 min then plug back in.
    Anthony_VZ
    **If someones post has helped you, please acknowledge their assistance by clicking the red thumbs up button to give them Kudos. If you are the original poster and any response gave you your answer, please mark the post that had the answer as the solution**
    Notice: Content posted by Verizon employees is meant to be informational and does not supersede or change the Verizon Forums User Guidelines or Terms or Service, or your Customer Agreement Terms and Conditions or plan

  • Why is the new firefox so slow hate it ?

    Why is the new Firefox so slow really hate i wish they would fix it ?

    Try Google Chrome. That one is really fast.

  • Why is the sound browser so slow during playback?

    Why is the sound browser so slow during playback? This problem seems to have no solution. This problem even occurs on my Mac Pro With 8 Cores... This problem is in its 3rd Generation since version 8... Even AU Plugins with built-in sound browsers trigger sounds in real time. Whats up Apple? I would love to find a solution after 5 yrs of using this program... U-Jean

    This Problem has been occurring before 2011 according to the link below....... *** Apple!!!
    http://www.logicprohelp.com/forum/viewtopic.php?t=70175

  • Why does the videos looks so slow

    why does the videos looks so slow only in the internet

    Many reasons, like what format they are, for instance Flash Videos will be slower.
    Any links to the slow ones?
    Which exact Mac do you have?

  • I was charged for a movie that never was downloaded, i asked for it but the conection was too slow and I never was able to have the movie that i asked for...how can i get it without being charged again, who could remove the chage from my Crecit card?

    i was charged for a movie that never was downloaded, i asked for it but the conection was too slow and I never was able to have the movie that i asked for...how can i get it without being charged again, who could remove the chage from my Crecit card?

    You may not be able to get a refund, since the terms of sale for the iTunes Store state that all sales are final. You can contact the iTunes Store, explain the reason for your request, and ask, though:
    http://www.apple.com/support/itunes/contact.html
    It's possible they'll make an exception for you, particularly if the problem was on their end preventing the movie from downloading in a reasonable time.
    Good luck.

  • I'm on a prepaid plan for the 4s, i want the hotspot option which isn't offered on the prepaid plan.  heard the connection is too slow on the 4s only worth it on the 5 or 5s. would you agree? not sure how much the hotspot would increase my monthly bill...

    i'm on a prepaid plan for the 4s, i want the hotspot option which isn't offered on the prepaid plan.  heard the connection is too slow on the 4s only worth it on the 5 or 5s. would you agree? not sure how much the hotspot would increase my monthly bill....

    To use the hotspot for any of those devices, I believe you have to switch to a postpaid account and plan. You can see the pricing for the available postpaid plans under the "Shop" area of the website.

  • What can be done to correct slow video or freezing in Adobe Premiere Elements 12? Sound plays fine but the video is too slow to even start a project.

    Sound plays fine but the video is too slow to even start a project.

    film78
    On what computer operating system is your Premiere Elements 12 running on? Have you updated 12 to 12.1 yet? If not, please do so by using an opened project's Help Menu/Update.
    Not enough information in order to help you.
    Looking for
    1. Properties of source media (including file extension and brand/model/settings of camera that recorded the video).
    2. Is problem restricted to one particular file in one particular project? What happens if you start a new project? What is the
    duration and size of the project when performance is slow and freezing sets in? What are you doing in the program when this happens?
    3. Using a pen and tablet device instead of a mouse?
    4. Does problem exist if antivirus and firewall(s) are disabled?
    5. Please describe computer environment, including dating on video card/graphics card driver version. Did you install the program to the
    default Local Disk C? Where are the Scratch Disks directed and how much free space there?
    Lots more questions, but let us start here and then decide what next based on your reply.
    Thank you.
    ATR

  • Error message trying to reproduce the demo songs on the pack. A message appears: The disk is too slow o there is an overloaded. My system is in Spanish so maybe the message is not exactly like this in English but I am sure you will get the idea. Thanks!

    When I try to reproduce the demo songs that comes with the Logic Studio pack a message pop out : The disk is too slow or there is an overload.
    Any help, please?

    spheric, thanks a lot!!!
    You are right, as soon I copied the songs to the HD all of them works perfect!
    Thanks a lot!!!

  • Why is the selection filter not remembered each time i start Ultiboard 10

    Why is the selection filter not remembered each time i start Ultiboard 10 the filter is differend from the last time i closed Ultiboard.
    Solved!
    Go to Solution.

    Hi there,
    Thanks for posting this. We've identified the root cause of this issue and have fixed this. This problem is fixed and should be available with our next maintenance release.
    Yi
    Software Developer
    National Instruments - Electronics Workbench Group

Maybe you are looking for