Is anyone able to explain really poor performance when using 'If Exists'?

Hello all.  We've recently had a performance spike when using the 'if exists' construct, which is a construct that we use through much of our code.  The problem is, it appears illogical since if can be removed via a tiny modification that does
not change the core code.
I can demonstrate  
This is the (simplified) format of the base original code.  It's purpose is to identify when a column value has changed comparing to a main table and a complex view
select 1 from MainTable m
inner join ComplexView v on m.col2 = v.col2
where m.col3 <> v.col3
This is doing a table scan, however the table only has 17000 rows while the view only has 7000 rows.  The sql executes in approximately 3 seconds.
However if we add the 'If Exists' construct around the original query, like such:
if exists (
select 1 from MainTable m
inner join ComplexView v on m.col2 = v.col2
where m.col3 <> v.col3
print 1
The sql now takes over 2 minutes to run.  Note that the core sql is unchanged.  All I have done is wrap it with 'If Exists'
I can't fathom why the if exists construct is taking so much longer, especially since the code code is unchanged, however more importantly I would like to understand why since we commonly use this type of syntax.
Any advice would be greatly appreciated

OK, that's interesting.  Adding the top 1 clause greatly affects the performance (in a bad way).
The original query (as below) still runs in a few seconds.
select 1 from MainTable m
inner join ComplexView v on m.col2 = v.col2
where m.col3 <> v.col3
The 'Top 1' query (as below) takes almost 2 minutes however.  It's exactly the same query, but with 'top 1' added to it.
select top 1 1 from MainTable m
inner join ComplexView v on m.col2 = v.col2
where m.col3 <> v.col3
I suspect that the top 1 is performing a very similar operation to the exists, in that it is 'supposed' to exit as soon as it finds a single row that satisfies it's results.
It's still not really any closer to making me understand what is causing the issue however.

Similar Messages

  • Poor performance when using kde desktop effect

    Hey,
    I'm having trouble when using kde effet (system settings -> desktop -> desktop effects).
    I have a dual core E5200 3 ghz, 2 GB memory pc8500 and an HD4850 using fglrx driver, but I got incredible bad performance when using desktop effect and watching video, I can barely watch a 800x600 video in full screen mode without having bad performance, X getting up to 40% cpu usage.
    Its really like my graphic card isnt handling the rendering stuff but 3D acceleration is working, I can play 3D game without problem so far (as long as the deskstop effect arent enabled cause the cpu have like a hard time handling both for recent game)
    So I guess its some trouble with 2D acceleration or something like that, I read that some people had such issue, but I didnt figure a way to fix it.
    Here is my xorg.conf, in case something is wrong with it :
    Section "ServerLayout"
    Identifier "X.org Configured"
    Screen 0 "aticonfig-Screen[0]-0" 0 0
    InputDevice "Mouse0" "CorePointer"
    InputDevice "Keyboard0" "CoreKeyboard"
    EndSection
    Section "Files"
    ModulePath "/usr/lib/xorg/modules"
    FontPath "/usr/share/fonts/misc"
    FontPath "/usr/share/fonts/100dpi:unscaled"
    FontPath "/usr/share/fonts/75dpi:unscaled"
    FontPath "/usr/share/fonts/TTF"
    FontPath "/usr/share/fonts/Type1"
    EndSection
    Section "Module"
    Load "dri2"
    Load "extmod"
    Load "dbe"
    Load "record"
    Load "glx"
    Load "dri"
    EndSection
    Section "InputDevice"
    Identifier "Keyboard0"
    Driver "kbd"
    EndSection
    Section "InputDevice"
    Identifier "Mouse0"
    Driver "mouse"
    Option "Protocol" "auto"
    Option "Device" "/dev/input/mice"
    Option "ZAxisMapping" "4 5 6 7"
    EndSection
    Section "Monitor"
    Identifier "Monitor0"
    VendorName "Monitor Vendor"
    ModelName "Monitor Model"
    EndSection
    Section "Monitor"
    Identifier "aticonfig-Monitor[0]-0"
    Option "VendorName" "ATI Proprietary Driver"
    Option "ModelName" "Generic Autodetecting Monitor"
    Option "DPMS" "true"
    EndSection
    Section "Device"
    ### Available Driver options are:-
    ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
    ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
    ### [arg]: arg optional
    #Option "ShadowFB" # [<bool>]
    #Option "DefaultRefresh" # [<bool>]
    #Option "ModeSetClearScreen" # [<bool>]
    Identifier "Card0"
    Driver "vesa"
    VendorName "ATI Technologies Inc"
    BoardName "RV770 [Radeon HD 4850]"
    BusID "PCI:8:0:0"
    EndSection
    Section "Device"
    Identifier "aticonfig-Device[0]-0"
    Driver "fglrx"
    BusID "PCI:8:0:0"
    EndSection
    Section "Screen"
    Identifier "Screen0"
    Device "Card0"
    Monitor "Monitor0"
    SubSection "Display"
    Viewport 0 0
    Depth 1
    EndSubSection
    SubSection "Display"
    Viewport 0 0
    Depth 4
    EndSubSection
    SubSection "Display"
    Viewport 0 0
    Depth 8
    EndSubSection
    SubSection "Display"
    Viewport 0 0
    Depth 15
    EndSubSection
    SubSection "Display"
    Viewport 0 0
    Depth 16
    EndSubSection
    SubSection "Display"
    Viewport 0 0
    Depth 24
    EndSubSection
    EndSection
    Section "Screen"
    Identifier "aticonfig-Screen[0]-0"
    Device "aticonfig-Device[0]-0"
    Monitor "aticonfig-Monitor[0]-0"
    DefaultDepth 24
    SubSection "Display"
    Viewport 0 0
    Depth 24
    EndSubSection
    EndSection
    Thank you for any help.

    Section "Device"
    ### Available Driver options are:-
    ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
    ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
    ### [arg]: arg optional
    #Option "ShadowFB" # [<bool>]
    #Option "DefaultRefresh" # [<bool>]
    #Option "ModeSetClearScreen" # [<bool>]
    Identifier "Card0"
    Driver "vesa"
    VendorName "ATI Technologies Inc"
    BoardName "RV770 [Radeon HD 4850]"
    BusID "PCI:8:0:0"
    EndSection
    and
    Section "Monitor"
    Identifier "Monitor0"
    VendorName "Monitor Vendor"
    ModelName "Monitor Model"
    EndSection
    I see no reason for those to be there.
    make a backup of your xorg.conf and remove / comment those lines.

  • Poor Performance when using Question Pooling

    I'm wondering if anyone else out there is experiencing
    Captivate running very slow when using question pooling. We have
    about 195 questions with some using screenshots in jpeg format.
    By viewing the Windows Task Manager, CP is using anywhere
    between 130 to 160 K worth of memory. What is going on here? It's
    hammering the system pretty hard. It takes a large effort just to
    reposition the screenshot or even move a distractor.
    I'm running this on a 3.20GHz machine with 3GB of RAM.
    Any Captivate Gurus out there care to tackle this one?
    Help.

    MtnBiker1966,
    I have noticed the same problem. I only have 60 slides with
    43 questions and the Question Pool appears to be a big drain on
    performance. Changing the buttons from Continue to Go to next slide
    helped a little, but performance still drags compared to not using
    a question pool. I even tried reducing the number of question
    pools, but that did not affect the performance any. The search
    continues.
    Darin

  • BIBean poor performance when using Query.setSuppressRows()

    Does anyone have experience in suppressing N/A cell values using BIBean? I was experimenting the use of Query.setSuppressRows(DataDirector.NA_SUPPRESSION). It does hide the rows that contains N/A values in a crosstab.
    The problem is that the performance degrades significantly when I started drilling down the hierarchy. Without calling the method, I was able to drill into the pre-aggregated hierarchy in a few seconds. But with setSuppressRows(), it took almost 15 minutes to do the same drill.
    Just for a comparison, I used DML to report on the same data that I wanted to drill into. With either 'zerorow' to yes or no, the data was fetched less than a second.
    Thanks for any help.
    - Wei

    At the moment we are hoping this will be fixed in a 10g database patch which is due early 2005. However, if you are using an Analytic Workspace then you could use OLAP DML to filter the zero and NA rows before they are returned to the query. I think this involves modifying the OLAP views that return the AW objects via SQL commands.
    Hope this helps
    Business Intelligence Beans Product Management Team
    Oracle Corporation

  • Poor performance when using skip-level hierarchies

    Hi there,
    currently we have big performance issues when drilling in a skip-level hierarchy (each drill takes around 10 seconds).
    OBIEE is producing 4 physical SQL statements when drilling f.e. into the 4th level (for each level one SQL statement). The statements runs in parallel and are pretty fast (the database doesn't need more than 0,5 seconds to produce the result), but ... and here we have probably somewhere a problem ... putting all the 4 results together in OBIEE takes another 8 seconds.
    This are not big datasets the database is returning - around 5-20 records for each select statement.
    The question is: why does it take so long to put the data together on the server? Do we have to reconfigure some parameters to make it faster?
    Please guide.
    Regards,
    Rafael

    If you really and exclusively want to have "OBIEE can handle such queries" - i.e. not touch the database, then you had best put a clever caching strategy in place.
    First angle of attack should be the database itself though. Best sit down with a data architect and/or your DBA to find the best setup possible physically and then when you've optimized that (with regard to the kind of queries emitted against it) you can move up to the OBIS. Always try t fix the issue as close to the source as possible.

  • Poor performance when using bind variable in report

    I have a report that takes 1 second to run if i 'hardcode' a particular value into the where clause of the report. However, if i now replace the hardcoded value with a bind variable and set the default value for the bind variable to be the (previous) hard coded value the report now takes 50 seconds to run instead of 1 second!!
    Has anyone else seen this behaviour - any suggestions to workaround this will be gratefully received

    More info
    SELECT patch_no, count(*) frequency
    FROM users_requests
    WHERE patchset IN (SELECT arps2.patchset_name
    FROM aru_bugfix_relationships abr, aru_bugfixes ab, aru_status_codes ac,
    aru_patchsets arps, aru_patchsets arps2
    WHERE arps.patchset_name = '11i.FIN_PF.E'
    AND abr.bugfix_id = ab.bugfix_id
    AND arps.bugfix_id = ab.bugfix_id
    AND abr.relation_type = ac.status_id
    AND arps2.bugfix_id = abr.related_bugfix_id
    AND abr.relation_type IN (601, 602))
    AND included ='Y'
    GROUP BY patch_no
    order by frequency desc, patch_no
    Runs < 1 sec from SQL navigator and from portal (if i hardcode the value for fampack.
    Takes ~50 secs if i replace with :fampack and set default value to 11i.FIN_PF.D

  • Poor performance when using drop down box on web report

    We are using dropdown box functionality in web reporting to allow easy selection of characteristics values. We have 4 dropdown boxes
    that represents Region, Area, Country and division.
    We need to use booked_values = 'Q' to show only relevant values for selection in the dropdown. However the issue is takes a long time for results to appear
    on the template. Read from Fact table is quick but process of deriving drop down values is very slow.
    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="GET_ITEM"/>
             <param name="NAME" value="DROPDOWNBOX_1"/>
             <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_FILTER_DDOWN"/>
             <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
             <param name="BORDER_STYLE" value="BORDER"/>
             <param name="GENERATE_CAPTION" value=""/>
             <param name="IOBJNM" value="ZPC_ORG14"/>
             <param name="BOOKED_VALUES" value="Q"/>
             <param name="TARGET_DATA_PROVIDER_1" value="DATAPROVIDER_1"/>
             ITEM:            DROPDOWNBOX_1
    </object>
    Do you have any suggestions on how to improve performance on drop down?
    Thanks, Jay

    Dear Jayant Dixit,
    1) If the values in the drop down box....are NOT dependent on user selection...then webserver can send them along with the first page....and cache them on client m/c...for multiple client/server dialogs....
    2) If the values are changing based on what the user selected from a previous input......then...you need to do some research on how SAP Webserver could optimize the "network traffic"......For example: a) Apache webserver has a module that compresses the content on the webserver side and then send to the client...b)A Client browser plugin decompresses the received packet and displays appropriately....
    3) We may need to research the latest SAP webserver capabilities....
    Good luck, BB

  • DOI - I_OI_SPREADSHEET, poor performance when reading more than 9999 record

    Hi,
    Please read this message in the [ABAP Performance and Tuning|DOI - I_OI_SPREADSHEET, poor performance when reading more than 9999 record; section and see if you have any advise.
    Best Regards,
    Marjo

    Hi,
    I met this issue when I tried to write vaule to massive fields of excel range.
    And I solve this issue by using CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_EXPORT.
    So, I think you may fix it in the same way.
    1. Select range in by the I_OI_SPREADSHEET
    2. Call method I_OI_DOCUMENT_PROXY->COPY_SELECTION
    3. Call method CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_IMPORT
    Cheers,

  • Does anyone know how to load ACR presets when using ACR in the creative cloud?

    Does anyone know how to load ACR presets when using ACR in the creative cloud?

    Moving the discussion to Adobe Camera Raw forum.
    Thanks,
    Atul Saini

  • Poor performance when dragging item within a list loaded with images - Flex 4

    Hi,
    I have a custom built List component that is using a TileLayout. I am using a custom itemRenderer to load images into this list from our server (in this test, 44 images rae loaded). I have enabled dragEnabled and dragMove so that I can move items around within the list. The problem comes when I start dragging an item. The dragging operation is very slow and clunky.
    When I move the mouse to drag the item, the dropIndicator does not get refreshed for a few seconds and the movement feels like my PC is lagging pretty badly. I've also noticed that during this time my CPU usage is spiking up to around 25-40%. The funny part is I can scroll the list just fine without any lag at all, but the minute I drag the application starts to lag really bad. I do have some custom dragOver code that I used to override the dragOverHandler of the list control, but the problem persists even if I take that code out. I've tried with useVirtualLayout set to both true and false and neither setting made a difference. 
    Any ideas as to what could be causing the poor performance and/or how I can go abouts fixing it?
    Thanks a lot in advance!

    Ahh, good call about the Performance profiler. I'm pretty new to the profiling thing with Flex (haven't used Builder Pro before
    the Flex 4 beta) so please forgive me
    I found some interesting things running the performance profiler but I'm not sure I understand what to make of it all. I cleared the Performance Profile data when right before I loaded the images into the list. I then moved some images around and then captured the Profiling Data (If I understand Adobe correctly, this is the correct way to capture performance information for a set of actions).
    What I found is there is a [mouseEvent] item that took 3101ms with 1 "Calls" (!!!!). When I drill down into that item to see the Method Statistics, I actually see three different Callees and no callers. The sum of the time it took the Callees to execute does not even come close to adding up to the 3101 ms (about 40ms). I'm not sure what I can make of those numbers, or if they are even meaningful. Any insight into these?
    The only other items that stand out to me are [pre-render] which has 863ms (Cumulative Time) / 639ms (Self Time), [enterFrameEvent] which has 746ms / 6ms (?!), and [tincan] (what the heck is tincan?) which has times of 521ms for both Cumulative and Self.
    Can anyone offer some insight into these numbers and maybe make some more suggestions for me? I apologize for my ignorance on these numbers - as I said, I'm new to the whole Flex profiling thing.
    Many thanks in advance!
    Edit: I just did another check, this time profiling only from the start of my drag to the end of my drop, and I still see [mouseEvent] taking almost 1000ms of Cumulative Time. However, when I double click that item to see the Method Statistics, no Callers or Callees are listed. What's causing this [mouseEvent] and how come it's taking so long?

  • Poor OEL5-3 performance when using over 1Gb of RAM

    Hi, I have a Linux distribution ( Oracle Enterprise Linux 5.3 i.e. Redhat ) that I have installed. It works fine when I used 2*512Mb dimms or replace them with a single 1Gb dimm. However when I try to go above 1 Gb the bootup and general performance deteriorates badly. The BIOS picks up the memory changes ok and I am using the same type of memory sticks. It makes no difference if I load a single memory channel with the 2 sticks or balance the sticks over the 2 channels - I still get poor performance. When I return to 1Gb of RAM performance is great
    In terms of install I just followed the Oracle Release note and Readme on the DVD itself. To be honest they are incredibly basic. There does not appear to be any specific OEL 5-3 installation manual on Technet. I simply followed the prompts on scereen and choose a default install
    I have seen quite a few hits concerning problems with performance over 1Gb for Linux such as having to enable Highmem support in the kernel - however I have not seen any instruction how to check or do this - any ideas ?

    jimthompson wrote:
    Hi, I have a Linux distribution ( Oracle Enterprise Linux 5.3 i.e. Redhat ) that I have installed. It works fine when I used 2*512Mb dimms or replace them with a single 1Gb dimm. However when I try to go above 1 Gb the bootup and general performance deteriorates badly. The BIOS picks up the memory changes ok and I am using the same type of memory sticks. It makes no difference if I load a single memory channel with the 2 sticks or balance the sticks over the 2 channels - I still get poor performance. When I return to 1Gb of RAM performance is great
    In terms of install I just followed the Oracle Release note and Readme on the DVD itself. To be honest they are incredibly basic. There does not appear to be any specific OEL 5-3 installation manual on Technet. I simply followed the prompts on scereen and choose a default install
    I have seen quite a few hits concerning problems with performance over 1Gb for Linux such as having to enable Highmem support in the kernel - however I have not seen any instruction how to check or do this - any ideas ?I still might have a concern about your hardware:
    Your two 512M sticks are undoubtably well matched and live comfortably together. Hopefully they did actually use dual channel mode.
    Your 1G lives well on its own as well
    However for the greater than 1G, ie 1G + 0.5G you may be using 2 sticks that do not live well together and are causing isses with delayed response. (At worst can only 0.5G is being recognised - (use grep MemTotal /proc/meminfo if necessary to check) ). In general issues seem better with DDR2 than with earlier memory in this regard. I suppose timing with memtest86 might be an interesting metric. I must admit myself i'd prefer to use 1g+1g or even 2g + 2g (i know on 32bit I might not see it all) rather than 1g+2g or 1g+0.5g.
    Anyway what I am trying to say is that hardware should not be eliminated as a possible cause at this stage.
    Rgds - bigdelboy

  • Poor performance when accessing a MSAS 2008 cube via BI Server

    I am having an issue with performance when accessing a MSAS 2008 cube via the BI Server.
    I think it has to do with the way that the MDX is being generated.
    Please could someone advise on any settings I could try or any known issues with the integration?
    Thanks,
    Kim Sarkin
    [email protected]

    Hi Kim,
    Sorry I can't help out, but, I'm curious how you got the AS 2008 drivers installed for use with OBIEE? I have an AS2008 environment, but, my OBIEE version only supports 2000 and 2005.
    Thanks,
    Mark

  • Iphone 4S takes really bad pics when using the flash. All the pics have a white haze. Is there a fix to this?

    When I try and click pics in low light with my iphone 4s, the quality is really poor with a white haze on all the pics. The iphone 4 had a similar problem and I upgraded thinking they may have fixed this. We tried taking some pics on NY's eve with the iphone but the result was really poor. Switched to my wife's blackberry and got amazing results. So I guess its a software related issue. If blackberry cameras can give such amazing pics with a flash why cant iphones? Apple please fix.

    @Holman - I only have a bumper on my phone, no screen protector or plastic cover but thanks for stating the obvious.
    @Dave - Posting some pics here which show the white haze when taking pics in low light using flash. I know numerous other iphone 4/4S owners who have the same complaint and also the forum is full of people having similar queries so I guess mine is not a one off case.
    As you can see there is a white haze in both these pics and every other pic I take in low light. Using this phone's camera in a nightclub is almost embarassing when blackberry users see the results.

  • Optimizing EtherCAT Performance when using Scan Engine

    Hello everyone,
    This week I have been researching and learning about the limitations of the LabVIEW's Scan Engine. Our system is an EtherCAT (cRIO 9074) with two slaves (NI 9144). We have four 9235s, two 9237s and two 9239 modules per chassis. That means we have a total of 144 channels. I have read that a conservative estimation for each scan is 10 usec. This means with our set up, assuming we only scan it would take 1.44 msec which would yield roughly a rate of 694 Hz. I know that when using a shared variable, the biggest bottle neck is transmitting the data. For instance, if you scan at 100 Hz, it'll be difficult to transmit that quickly, so it's best to send packets of scans (which you can see in my code).
    With all of that said, I'm having difficulties scanning any faster than 125 Hz without railing out my CPU. I can record at 125 Hz at 96% of the CPU usage but if I go down to 100 Hz, I'm at 80%. I noticed that the biggest factor of performance comes when I change my top loop's, the scan loop, period. Scanning every period is much much more demanding than every other. I have also adjusted the scan period on the EtherCAT's preferences and I have the same performance issues. I have also tried varying the transmission frequency(bottom loop), and this doesn't affect the performance at all.
    Basically, I have a few questions:
    1. What frequency can I reasonably expect to obtain from the EtherCAT system using the Scan Engine with 144 channels?
    2. What percent of the CPU should be used when running a program (just because it can do 100%, I know you shouldn't go for the max. Is 80% appropriate? Is 90% too high?)
    3.Could you look through my code and see if I have any huge issues? Does my transmission loop need to be a timed structure? I know that it's not as important to transmit as it is to scan, so if the queue doesn't get sent, it's not a big deal. This is my first time dealing with a real time system, so I wouldn't be surprised if that was the case.
    I have looked through almost every guide I could find on using the scan engine and programming the cRIO (that's how I learned the importance of synchronizing the timing to the scan engine and other useful facts) and haven't really found a definitive answer. I would appreciate any help on this subject.
    P.S. I attached my scan/transmit loop, the host program and the VI where I get all of the shared variables (I use the same one three times to prevent 144 shared variables from being on the screen at the same time).
    Thanks,
    Seth
    Attachments:
    target - multi rate - variables - fileIO.vi ‏61 KB
    Get Strain Values.vi ‏24 KB
    Chasis 1 (Master).vi ‏85 KB

    Hi,
    It looks like you are using a 9074 chassis and two 9144 chassis, all three full with Modules and you are trying to read all the IO channels in one scan?
    First of all, if you set your scan engine speed for the controller (9074), then you have to synchronize your Timed Loop to the Scan Engine and not to use a different timebase as you do in your scan VI.
    Second the best performance can be achieved with I/O variables, not shared variables and you should make sure to  not allocate memory in your timed Loop.  memory will be allocated if an input of a variable is not connected, like the error cluster for example or if you create Arrays from scratch as you do in your scan VI.
    If you resolve all these Issues you can time the code inside your Loop to see how long it really takes and adjust your scan time accordingly.  The 9074 does not have that much power so you should not expect us timing. 500 Hz is probably a good estimate for the max. Performance for 144 channels and depending on how much time the additional microstrain calculation takes.
    The ECAT driver brings examples which show how to program these kinds of Apps. Another way of avoiding the variables would be the programmatic approach using the variable API.
    DirkW

  • Really poor performances

    Hi everyone,
    first of all, sorry for my poor english.
    I'm trying developing a simple app using Flash CS5.
    I've tested my app on a pc and it was ok but when I tried it on the Iphone performances became pretty bad.
    I did some animation  using the timeline and reading this forum I realized that probably this is the reason of my problems.
    Now I'm trying to find a best way to make my animation running smoothly.
    I'm not such experienced programmer so maybe things really oblivious for you could be new for me.
    I'll start fixing thing step by step, so this is my first question:
    My app start with a picture that goes from alpha=0 to alpha=100 and then back to 0, doing it using the timeline produce a choppy animation.
    I' ve also tried to convert my animation in this code:
    import fl.motion.Animator;
    var test_xml:XML = <Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
    <source>
    <Source frameRate="24" x="320" y="480" scaleX="1" scaleY="1" rotation="0" elementType="graphic" symbolName="Tween 21">
    <dimensions>
    <geom:Rectangle left="-320" top="-480" width="320" height="480"/>
    </dimensions>
    <transformationPoint>
    <geom:Point x="1" y="1"/>
    </transformationPoint>
    </Source>
    </source>
    <Keyframe index="0" tweenSnap="true" tweenSync="true">
    <color>
    <Color alphaMultiplier="0"/>
    </color>
    <tweens>
    <SimpleEase ease="0"/>
    </tweens>
    </Keyframe>
    <Keyframe index="29">
    <color>
    <Color/>
    </color>
    <tweens>
    <SimpleEase ease="0"/>
    </tweens>
    </Keyframe>
    <Keyframe index="78">
    <color>
    <Color/>
    </color>
    <tweens>
    <SimpleEase ease="0"/>
    </tweens>
    </Keyframe>
    <Keyframe index="106">
    <color>
    <Color alphaMultiplier="0" />
    </color>
    </Keyframe>
    </Motion>;
    var test_animator:Animator = new Animator(test_xml, test);
    test_animator.play();
    But the animation is still slow.
    I'm sure there is a more efficent way to do this. Someone could help me?

    @Arnold, the slowdown occurs because each bitmap (as you cycle through them) is being sent to the GPU. Transferring data to the GPU is slow, but once it is there it is fast.
    Sorry, Arnold, this is because I missed out some code - when the frames are cached, they should be placed outside the screen area on the stage. Something like:
    // This is the initialisation and should only happen once. This takes each of
    // the frames of animation (BitmapData) and place them inside a Bitmap. These
    // are stored in an array, and placed offscreen so they are not visible. This last
    // is done so that Flash caches the BitmapData objects on the GPU. I have
    // read that if the objects are not on stage, they are flushed from the GPU.
    var animFrames : Vector.<Bitmap>;
    var animFrameIndex : int = 0;
    var frameCounter : int = 0;
    animFrames = new Vector.<Bitmap>();
    animFrames.push( new Bitmap( new AnimFrame1(0,0), PixelSnapping.ALWAYS, false ) );
    animFrames.push( new Bitmap( new AnimFrame2(0,0), PixelSnapping.ALWAYS, false ) );
    animFrames.push( new Bitmap( new AnimFrame3(0,0), PixelSnapping.ALWAYS, false ) );
    // --- this was missing
    // Place the frames off screen to force the GPU to cache them. Make sure that
    // they do not (completely) overlap or Flash may not cache them.
    var i : int;
    var xPos : int = -100;
    for (i=0; i<animFrames.length; i++){
         xPos -= animFrames[i].width;
         animFrames[i].x = xPos;
         addChild(animFrames[i]);
    // --- this was missing
    // This is your sprite. It's bitmapData is set to one of the ones in your vector
    var mySprite : Bitmap = new Bitmap( animFrames[0].bitmapData, PixelSnapping.ALWAYS, false );
    // Register your game loop
    addEventListener(Event.ENTER_FRAME,onEnterFrameDraw);
    // Game loop that runs every frame, but only updates the animation every second frame. A
    // much better technique would be to use the elapsed time since the app started (using
    // getTimer() ) to determine when to change frames. This avoids any differences in speed
    // between devices (e.g. iPhone 1st gen, iPhone 4 etc).
    function onEnterFrameDraw( e : Event ):void{
      // Odd numbers only
      if (frameCounter & 1){
        // Update animation to next frame
        mySprite.bitmapData = animFrames[ animFrameIndex ];
        // Update frame index to next frame of animation
        animFrameIndex++;
        if (animFrameIndex == animFrames.length) animFrameIndex = 0;
      frameCounter++;
    Edited 1 Nov 2010: Based on information in this thread, it seems you cannot stack the images to cache them as Flash is smart enough not to cache any hidden images. I have updated the code to stagger the images. I wonder, though, if Flash is smart enough to cache them if they are off-screen?

Maybe you are looking for